The viz_gridprop function builds a proportional symbol map
aggregated on a spatial grid. It first generates a grid from the input spatial
data frame, then displays aggregated values within each cell using proportional symbols.
Usage
viz_gridprop(
map,
data = NULL,
var,
grid = "square",
step = 15,
level = 1,
coords = "geo",
missing = "white",
symbol = "circle",
k = 10,
width = 30,
straight = 0,
fixmax = NULL,
legend = TRUE,
leg_type = "separate",
leg_pos = c(10, 10),
leg_title = NULL,
...
)Arguments
- map
A
geovizmap created withviz_create.- data
A spatial dataframe Use
datato enable iteration over features.- var
character. Name of the numeric variable used for aggregation and symbol scaling.
- grid
character. Optional. Type of grid used for aggregation (default "square"). One of: "square", "dot", "diamond", "hexbin", "hex", "triangle", "arbitrary", "random", "h3", "h3geo", "hexgeo", "hexbingeo", "square_sph".
- step
numeric. Optional. Grid resolution (default 15).
- level
numeric. Optional. Subdivision level for hierarchical grids (default 1).
- coords
character. Optional. Coordinate system (default "geo"). One of: "geo", "svg".
- missing
character. Optional. Color for missing values (default "white").
- symbol
character. Optional. Symbol type (default "circle"). One of: "circle", "square", "spike", "halfcircle".
- k
numeric. Optional. Size of the largest symbol (default 10).
- width
numeric. Optional. Width of spike symbols (default 30).
- straight
numeric. Optional. Curvature of spike symbols (default 0). Value between 0 (curved) and 1 (straight).
- fixmax
numeric. Optional. Maximum value for symbol scaling. Useful for map comparability.
- legend
logical. Optional. Whether to display legend (default TRUE).
- leg_type
character. Optional. Legend type (default "separate"). One of: "nested", "separate".
- leg_pos
numeric vector. Optional. Legend position (default c(10, 10)).
- leg_title
character. Optional. Legend title (default
var).- ...
Additional parameters passed to choropleth rendering (same as
viz_choro). With theleg_prefix, you can configure the legend. For example:leg_title,leg_subtitle,leg_note, etc.
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
cities <- st_read(
system.file("gpkg/cities.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(projection = "EqualEarth") |>
viz_path(datum = world, fill = "#f1f3f5") |>
viz_gridprop(data = cities, var = "population") |>
viz_render()