The viz_path function draws geometries from a spatial data frame
as SVG paths. This function can be used to display polygons, lines, or points,
and supports styling, simplification, and interaction.
Usage
viz_path(
map,
data = NULL,
datum = NULL,
id = NULL,
coords = "geo",
clip = TRUE,
fill = NULL,
stroke = NULL,
strokeWidth = 1,
tip = FALSE,
simplify = FALSE,
rewind = FALSE,
rewindPole = FALSE,
clipOutline = 0,
r = 3,
...
)Arguments
- map
A
geovizmap created withviz_create.- data
A spatial dataframe Use
datato enable iteration (e.g. for styling with functions).- datum
A spatial dataframe Use
datumif no iteration is needed.- id
character. Optional. Unique layer id.
- coords
character. Optional. Coordinate system (default "geo"). Use
"svg"if coordinates are already expressed in the SVG coordinate space.- clip
logical. Optional. Whether to clip geometries with the outline (default TRUE).
- fill
character or function. Optional. Fill color. Functions can be used for choropleth maps or typologies.
- stroke
character or function. Optional. Stroke color. Functions can be used for choropleth maps or typologies.
- strokeWidth
numeric or function. Optional. Stroke width (default 1).
- tip
logical or function. Optional. Tooltip definition (default FALSE). Use TRUE to display all fields.
- simplify
numeric, vector, or logical. Optional. Geometry simplification (default FALSE). TRUE for automatic simplification, numeric for fixed tolerance, or vector
c(k1, k2)for dynamic simplification depending on zoom level.- rewind
logical. Optional. Rewind polygon rings to correct winding order (default FALSE).
- rewindPole
logical. Optional. Special rewinding for geometries crossing poles or the dateline (default FALSE).
- clipOutline
numeric or logical. Optional. Clip geometries near the antimeridian and poles (default 0). If TRUE, uses 0.01 degrees.
- r
numeric. Optional. Radius for point geometries (default 3). You can also use the shorthand
r.- ...
Additional SVG attributes (e.g.
strokeDasharray,opacity,strokeLinecap, etc.).
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(projection = "EqualEarth") |>
viz_path(data = world, fill = "#38896F", stroke = "white") |>
viz_render()