ol_scale_iconsize_continuous: Icon Size Scale (Continuous)

View source: R/scales.R

ol_scale_iconsize_continuousR Documentation

Icon Size Scale (Continuous)

Description

Specify a continuous size mapping for an icon layer.

Usage

ol_scale_iconsize_continuous(low.val, high.val, low.size = 0.33,
  high.size = 0.75, name = NULL, na.size.val = 0.33,
  legend.breaks = NULL, display = FALSE, display.icon.img.src = NULL)

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.

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.

display.icon.img.src

character path to image file to use in size legend. If NULL, the first image supplied to the icon layer will be used.

Details

This method maps OpenLayers point (icon) 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 an "iconsize" 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 the target.icon.width assigned to the layer.

Value

list of class Scale.IconSize.Continuous.

See Also

ol_map, ol_geom_icon,

Examples

some.r.servers <- matrix(
    c(
        144.964,-37.798,
        -122.920,49.278,
        121.494,31.307,
        25.083,35.307,
        -21.930,64.149,
        11.877,45.407,
        -99.200,19.345,
        5.322,60.388,
        -8.224,39.400,
        -8.616,41.147,
        -73.953,40.768,
        20.304,63.821,
        8.548,47.376,
        33.031,35.247,
        -78.938,36.001,
        -123.279,44.564,
        -96.797,32.777
    ),
    byrow=TRUE,
    ncol=2
)
r.server.df <- data.frame(
    server.name=c(
        'School of Mathematics and Statistics, University of Melbourne',
        'Simon Fraser University, Burnaby',
        'Shanghai University',
        'University of Crete',
        'Marine Research Institute',
        'University of Padua',
        'Instituto Tecnologico Autonomo de Mexico',
        'University of Bergen',
        'RadicalDevelop, Lda',
        'University of Porto',
        'Four Dots',
        'Academic Computer Club, UmeƄ University',
        'ETH Zurich',
        'Middle East Technical University Northern Cyprus Campus, Mersin',
        'Duke University, Durham, NC',
        'Oregon State University',
        'Revolution Analytics, Dallas, TX'
    ),
    server.value = runif(17)*10,
    stringsAsFactors=FALSE
)
r.icon <- "https://www.r-project.org/Rlogo.png"
## If width is not provided image must be local
## and png package must be installed.
r.icon.width <- 200 
r.map <- ol_map(
    center=c(-100,30),
    zoom=3
) + 
    streetmap()+
    ol_geom_icon(
        some.r.servers,
        r.icon,
        mapping=ol_aes(iconsize=server.value),
        df = r.server.df,
        name="R Servers",
        icon.size.scalar='autoscale',
        src.img.width=r.icon.width,
        toggle.control=TRUE,
        tooltip=r.server.df$server.name
) +
    ol_scale_iconsize_continuous(
    low.val=0,
    high.val=10,
    legend.breaks=c(0,2.5,5,7.5,10),
    display=TRUE
)
## Not run: 
# Oave as HTML and open in browser
ol_map2HTML(
  r.map,
  'R-servers.html'
)
browseURL("R-servers.html")

## End(Not run)

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