ol_geom_circle: OpenLayers Circle Layer

View source: R/layer_circle.R

ol_geom_circleR Documentation

OpenLayers Circle Layer

Description

Function to create a circle layer to add to an OpenLayers Map object.

Usage

ol_geom_circle(circle.obj, mapping = ol_aes(), name = NULL,
  df = NULL, toggle.control = FALSE, fill = "#00FF0090",
  fill.opacity = 0.5, lwd = 1, ol.lty = list(), color = "#000000",
  label = NULL, label.params = list(), tooltip = NULL,
  tooltip.params = list())

Arguments

circle.obj

matrix containing three columns: center longitude, center latitude, and radius respectively. Each row yields a single circle feature in the resulting layer.

mapping

list created by ol_aes.

name

character Layer name.

df

data.frame with same number of rows as circle.obj. Used for aestheic mapping.

toggle.control

logical indicating whether this layer will have a visibility toggle.

fill

character color string, or vector of color strings. Used only if no fill aesthetic is provided in mapping

fill.opacity

numeric in [0,1]. Controls circle opacity if no opacity provided in fill or fill aesthetic.

lwd

numeric circle border width. Used only if no lwd aesthetic is provided in mapping

ol.lty

(experimental) numeric vector with length > 1, or list of such vectors. Used only if no ol.lty aesthetic is provided in mapping. See OpenLayers ol/style/Stroke Documentation, 'lineDash' property for more information.

color

character border color string, or vector of color strings. Used only if no color aesthetic is provided in mapping

label

character vector of length nrow(circle.obj) of feature labels.

label.params, tooltip.params

named lists (e.g., list(property=value)) of label and tooltip position and format parameters. See ol_geom_polygon documentation.

tooltip

character vector of length nrow(circle.obj) of feature tooltip popups.

Details

This function stores the data required to generate an OpenLayers vector layer with features using circle geometries. See OpenLayers Circle Documentation for details.

Value

A list object of class Layer.Circle.

Aesthetics

See Also

ol_aes, ol_map, ol_geom_polygon

Examples

miami.circles <- matrix(
    c(
        -80.885+runif(10), #Longitudes
        25.282618+runif(10), #Latitudes
        rnorm(10,2000,500) # Radii in meters
    ),
    ncol=3
)
aesthetic.df <- data.frame(
    type=sample(c("A","B"),10,replace=TRUE),
    value=runif(10)*10
)
miami.OSM.basemap <- ol_map(
    center=c(-80.385790,25.782618),
    zoom=9
    ) +
   streetmap()
circle.layer<-ol_geom_circle(
        miami.circles,
        df = aesthetic.df,
        mapping=ol_aes(fill=type),
        lwd=2,
        name="Meaningless Miami Circles",
        toggle.control=TRUE,
        color="#000000FF",
        tooltip=sprintf("%1.2f",aesthetic.df$value)
        )
circle.fill <- ol_scale_fill_discrete(
        display=TRUE,
        preserve.opacity=TRUE
    )
circles <- miami.OSM.basemap + circle.layer + circle.fill

## Not run: 
# Output to file and view
ol_map2HTML(
  circles,
  'miami_circles.html',
  map.heading="Miami Shapes",
  map.note="Note: Mouseover popup values are
    independent of shape size &amp; color."
)
browseURL("miami_circles.html")

## End(Not run)

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