ol_scale_size_continuous: Point Size Scale (Continuous)

View source: R/scales.R

ol_scale_size_continuousR Documentation

Point Size Scale (Continuous)

Description

Specify a continuous size mapping for a point layer.

Usage

ol_scale_size_continuous(low.val, high.val, low.size = 0.33,
  high.size = 0.75, name = NULL, na.size.val = 0.33,
  draw.fill = NULL, legend.breaks = NULL, display = FALSE)

Arguments

low.val

numeric the minimum variable value to be mapped to the smallest size.

high.val

numeric the maximum variable value to be mapped to the largest size.

low.size

numeric smallest size scalar.

high.size

numeric largest size scalar.

name

character the scale name.

na.size.val

numeric the size scalar assigned to non-numeric 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 an img tag.

Details

This method maps OpenLayers point feature sizes to continuous 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 variable. If no such layer exists, attempts to add this type of scale will result in a warning. Attempt to apply this scale to a non-numeric variable will throw an error.

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.Continuous.

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.numeric # continuous mapping
        ), 
        name="Point",
        marker="pin",
        fill='green',
        toggle.control=TRUE,
        tooltip=sprintf("%1.2f",point.df$pt.numeric)
) + 
    ol_scale_size_continuous(
    high.val=10,
    low.val=0,
    high.size=0.66,
    low.size=0.33,
    draw.fill='green',
    legend.breaks=c(0,3.33,6.67,10),
    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.