Classifies column into class_count numeric ranges and colors each range
from colormap, producing the same graduated symbology the application's
Style panel builds from the interface.
Arguments
- map
A GeoLibre widget.
- data
GeoJSON as a parsed list (a
FeatureCollection,Feature, or bare geometry), a JSON string, a file path, an HTTP(S) URL, or ansfobject. A URL or file is read and inlined into the project, up to a 50 MB limit; for larger datasets preferadd_vector(), which lets the browser stream the source.- column
Name of the numeric feature property to classify.
- name
Layer name.
- class_count
Number of classes, clamped to between 2 and 12.
- colormap
A color ramp name from
color_ramp_names().- scheme
Classification scheme,
"equal-interval"or"quantile".- style
Named list of GeoLibre style overrides such as
fillColor,strokeColor, andstrokeWidth.- visible
Whether the layer is initially visible.
- opacity
Layer opacity from zero to one.
- ...
Additional style overrides given as named arguments, merged into
style.add_geojson(map, data, fillColor = "red")andadd_geojson(map, data, style = list(fillColor = "red"))are equivalent.
See also
classify_layer() to symbolize a layer that is already on the map.
Examples
counties <- list(
type = "FeatureCollection",
features = list(
list(
type = "Feature", properties = list(pop = 100),
geometry = list(type = "Point", coordinates = c(-77, 39))
),
list(
type = "Feature", properties = list(pop = 900),
geometry = list(type = "Point", coordinates = c(-76, 40))
)
)
)
map <- geolibre() |>
add_choropleth(counties, column = "pop", colormap = "blues", class_count = 3)
stopifnot(map$x$project$layers[[1]]$style$vectorStyleMode == "graduated")