ol_scale_size_discrete: Point Size Scale (Discrete)

View source: R/scales.R

ol_scale_size_discreteR Documentation

Point Size Scale (Discrete)

Description

Specify a discrete size mapping for a point layer.

Usage

ol_scale_size_discrete(size.vector = NULL, name = NULL,
  na.size.val = 0.33, draw.fill = NULL, legend.breaks = NULL,
  display = FALSE)

Arguments

size.vector

numeric named vector of the form c(value=width). If NULL, a default size mapping is assigned.

name

character scale name.

na.size.val

numeric the size scalar assigned to unrecognized or NA values.

draw.fill

character fill color for drawing points in the legend only.

legend.breaks

numeric ordered vector of variable values to display in the legend.

display

logical indicating whether to draw the scale for output in the HTML. If TRUE, a bitmap will be created and sourced in the HTML in one or more img tags.

Details

This method maps OpenLayers point feature sizes to a discrete set of variable values. This scale can be added to an Ol.Map S3 object only if the Ol.Map object has a layer with a "size" mapping to a numeric, character, or factor variable. If no such layer exists, attempts to add this type of scale will result in a warning.

Size inputs to this method are applied as scalars to the icon widths. A size value of 1 translates to an icon width of 40 pixels for "pin" markers, or 20 pixels for "dot" markers.

Value

list of class Scale.Size.Discrete.

See Also

ol_map, ol_geom_point,

Examples

point.matrix <- matrix(
    c(
        -80.885+runif(10),
        25.223+runif(10)
    ),
    ncol=2
)
point.df <- data.frame(
    pt.type=sample(c("A","B"),10,replace=TRUE),
    pt.numeric=runif(10)*10
)
miami.points.map <- ol_map(
    center=c(-80.385790,25.782618),
    zoom=10
) + 
    streetmap()+
    ol_geom_point(
        point.matrix,
        df=point.df,
        mapping=ol_aes(
            size=pt.type # continuous mapping
        ), 
        name="Point",
        marker="pin",
        fill='green',
        toggle.control=TRUE,
        tooltip=point.df$pt.type
) + 
    ol_scale_size_discrete(
    c(A=1,B=0.5),
    name="Point Type",
    draw.fill='black',
    display=TRUE
)
## Not run: 
# Oave to file and open on browser
ol_map2HTML(
  miami.points.map,
  'pointsizes.html'
)
browseURL('pointsizes.html')

## End(Not run)

cemarks/ROpenLayers documentation built on March 31, 2022, 12:05 p.m.