ol_scale_iconsize_discrete: Icon Size Scale (Discrete)

View source: R/scales.R

ol_scale_iconsize_discreteR Documentation

Icon Size Scale (Discrete)

Description

Specify a discrete size mapping for an icon layer.

Usage

ol_scale_iconsize_discrete(size.vector = NULL, name = NULL,
  na.size.val = 0.33, legend.breaks = NULL, display = FALSE,
  display.icon.img.src = NULL)

Arguments

size.vector

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

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 discrete variable values. This scale can be added to an Ol.Map S3 object only if the Ol.Map object has a layer with a "iconsize" 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 the target.icon.width assigned to the layer.

Value

list of class Scale.IconSize.Discrete.

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.type = sample(c("A","B","C"),17,replace=TRUE),
    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.type),
        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.type
) +
    ol_scale_iconsize_discrete(
    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.