ol_geom_point: OpenLayers Point Layer

View source: R/layer_point.R

ol_geom_pointR Documentation

OpenLayers Point Layer

Description

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

Usage

ol_geom_point(point.obj, mapping = ol_aes(), name = NULL, df = NULL,
  toggle.control = FALSE, fill = "#00FF00", fill.opacity = 1,
  marker = "pin", size = 0.5, label = NULL, label.params = list(),
  tooltip = NULL, tooltip.params = list())

Arguments

point.obj

SpatialPointsDataframe, SpatialPoints, or a matrix containing columns of point longitudes and latitudes, respectively.

mapping

list created by ol_aes. Used for aestheic mapping.

name

character Layer name.

df

data.frame with same number of rows as point.obj coordinate matrix.

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.

marker

character. The 'pin' marker draws map pointers similar to most web map applications. The 'dot' or 'point' markers render as cicular points on the map. Other marker types are not supported by this method.

size

numeric point icon size scalar or vector scalars. Used only if no size aesthetic is provided in mapping. A value of 1 translates to an icon width of 40 pixels for "pin" markers, or 20 pixels for "dot" markers.

label

character vector of point 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 point feature tooltip popups.

Details

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

Value

A list object of class Layer.SpatialPoint.

Aesthetics

  • fill

  • size

See Also

ol_aes, ol_map, ol_geom_polygon, ol_geom_circle, ol_geom_line, ol_geom_icon

Examples

point.matrix <- matrix(
    c(
        -80.885+runif(10),
        25.282618+runif(10)
    ),
    ncol=2
)
point.df <- data.frame(
    pt.type=sample(c("A","B"),10,replace=TRUE),
    pt.value=runif(10)*10
)
miami.map <- ol_map(
    center=c(-80.385790,25.782618),
    zoom=9
) +
    streetmap()
miami.points <- ol_geom_point(
    point.matrix,
    df=point.df,
    mapping=ol_aes(fill=pt.type,size=pt.value),
    name="Random Points of Interest",
    marker="pin",
    toggle.control=TRUE,
    tooltip=point.df$pt.type
)
size.scale <- ol_scale_size_continuous(
    display=TRUE,
    draw.fill='green'
)
fill.scale <- ol_scale_fill_discrete(
    c(B='red',A='green'),
    display=TRUE
)
miami.points.map <- miami.map +
    miami.points +
    size.scale +
    fill.scale

## Not run: 
# Output to file and view
ol_map2HTML(
  miami.points.map,
  'Miami_points.html'
)
browseURL('Miami_points.html')

## End(Not run)

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