View source: R/map_choropleth.R
choropleth | R Documentation |
Creates a choropleth map from an 'sf' object, typically produced
by points_to_polygon()
. Polygons are shaded according to values in a
specified column, with clustering based on the Fisher–Jenks algorithm. This
method minimizes within-class variance and maximizes between-class variance,
making it a common choice for choropleth maps.
choropleth(
sf_object,
value = "output",
id_name = "areaname",
mode = "plot",
n = 7,
legend_title = "Clustering",
palette = "viridis"
)
sf_object |
An object of class |
value |
A string giving the name of the column used to shade the polygons. |
id_name |
A string giving the name of the column containing polygon IDs (used for tooltips in interactive mode). |
mode |
A string indicating whether to create a static map
( |
n |
Integer; number of clusters. Default is |
legend_title |
A string giving the legend title. |
palette |
A palette name or vector of colors. See
|
The function uses the Fisher–Jenks algorithm
(style = "fisher"
) to classify values into n
groups.
A tmap
object (static or interactive, depending on
mode
).
Martin Haringa
test <- points_to_polygon(nl_provincie, insurance, sum(amount, na.rm = TRUE))
choropleth(test)
choropleth(test, id_name = "areaname", mode = "view")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.