Learn R Programming

mapview (version 2.2.0)

addLargeFeatures: Add moderately large datasets with up to ~100k features to a map.

Description

This function allows users to add moderately sized datasets to a leaflet or mapview map. Things are drawn on a html canvas for performance. Feature querying is supported but only at higher zoom levels to preserve performance.

Usage

addLargeFeatures(map, data, color = "#03F", weight = 1, radius = 8,
  opacity = 1, fillOpacity = 0.6, canvasOpacity = 0.5,
  group = deparse(substitute(data)), maxpoints = getMaxFeatures(data),
  attributes = NULL, ...)

Arguments

map

a mapview or leaflet object.

data

the data to be added to the map.

color

color of the features. This can be a single character value, a vector of character values or a function that takes argument n to create a vector of n colors.

weight

the weight of the lines.

radius

the radius of the circleMarkers (ignored for lines/polygons).

opacity

the opacity of the stroke paths.

fillOpacity

opacity of the fill (for circleMarkers and polygons).

canvasOpacity

the opacity of features when rendered on canvas.

group

the name of the group the data layer should belong to. THIS NEEDS TO BE A VALID CHARACTER STRING, I.E. CANNOT BE 'NA' OR 'NULL'!

maxpoints

see mapview for details.

attributes

an optional attribute table (data.frame) to be used for popups. If NULL (the default) popups will show only the feature ID.

...

currently not used.

Examples

Run this code
# NOT RUN {
library(sf)
library(ggmap)

data(crime)
crime <- crime[complete.cases(crime), ]
crime_sf <- st_as_sf(crime, coords = c("lon", "lat"), crs = "+init=epsg:4326")

mapview(crime_sf, zcol = "offense", cex = 3)

# }
# NOT RUN {

# }

Run the code above in your browser using DataLab