ol_aes: Aesthetic Mappings

View source: R/ol_map_base.R

ol_aesR Documentation

Aesthetic Mappings

Description

Map variables to layer aesthetics.

Usage

ol_aes(...)

Arguments

...

comma-separated mappings of the form 'aesthetic=variable'. Available aesthetics for mapping are layer specific and are listed in the documentation for each layer type. Unavailable or unrecognized aesthetics are ignored. Variables must correspond to names in the layer's input data.frame, otherwise an error is thrown.

Details

This function replicates a subset of the functionality of the ggplot2 aes function. It does not allow for variable transformations or functions of multpile varuables. These operations must be completed a priori by the user.

Value

A list of aesthetic mappings.

See Also

ol_geom_polygon, ol_geom_line, ol_geom_point, ol_geom_icon, ol_geom_circle

Examples

polygon.matrix1 <- matrix(
    c(
        -80.385+c(0,0.05,0.05,0,0),
        25.782618+c(0,0,0.05,0.05,0)
    ),
    ncol=2
)
polygon.matrix2 <- matrix(
    c(
        -80.34+c(0,0.05,0.025,0),
        25.73++c(0,0,0.025*sqrt(3),0)
    ),
    ncol=2
)
polygon.list<-list(polygon.matrix1,polygon.matrix2)
polygon.df <- data.frame(shape=c("rectangle","triangle"),no=c(1,2))
miami.OSM.basemap <- ol_map(
    center=c(-80.385790,25.782618),
    zoom=9
    ) +
   streetmap()
polygon.layer <- ol_geom_polygon(
    polygon.list,
    mapping=ol_aes(
        fill=no,
        lwd=shape
    ),
    df=polygon.df,
    name="Miami Polygons",
    toggle.control=TRUE,
    tooltip=polygon.df$no
)
polygon.fill.scale <- ol_scale_fill_discrete(
    c("1"="red","2"="green"),
    opacity=0.5,
    display=TRUE,
    name="Number"
)
polygon.linewidth.scale <- ol_scale_lwd_discrete(
    display=TRUE,
    name="Shape"
)
polygons.over.miami <- miami.OSM.basemap +
    polygon.layer +
    polygon.fill.scale +
    polygon.linewidth.scale

## Not run: 
ol_map2HTML(
  polygons.over.miami,
  'miami_polygons.html',
  map.heading="Miami Shapes",
  map.note="Note: Mouseover popup values are
    independent of shape size &amp; color."
)
browseURL("miami_polygons.html")

## End(Not run)

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