The viz_circle function draws circles on the map from a spatial
data frame or from a single position. It can be used to create proportional symbol maps
with optional collision avoidance.
Usage
viz_circle(
map,
data = NULL,
id = NULL,
pos = c(0, 0),
r = 10,
k = 50,
fixmax = NULL,
dodge = FALSE,
iteration = 200,
sort = NULL,
descending = NULL,
coords = "geo",
fill = NULL,
stroke = "white",
tip = FALSE,
...
)Arguments
- map
A
geovizmap created withviz_create.- data
object. Optional. A spatial data frame.
- id
character. Optional. Unique layer id.
- pos
numeric vector. Optional. Position of a single circle (default c(0, 0)).
- r
numeric or character. Optional. Circle radius (default 10). Can be a fixed value or the name of a field containing numerical values.
- k
numeric. Optional. Radius of the largest circle (default 50).
- fixmax
numeric. Optional. Value corresponding to the circle of radius
k. Useful to ensure comparability between maps.- dodge
logical. Optional. Avoid circle overlap (default FALSE).
- iteration
numeric. Optional. Number of iterations for dodging (default 200).
- sort
character or function. Optional. Field name or function to sort circles.
- descending
logical. Optional. Sorting order.
- coords
character. Optional. Coordinate system (default "geo"). Use
"svg"if coordinates are already expressed in the SVG coordinate space.- fill
character or function. Optional. Fill color.
- stroke
character or function. Optional. Stroke color (default "white").
- tip
logical or function. Optional. Tooltip definition (default FALSE). Use TRUE to display all fields.
- ...
Additional SVG attributes (e.g.
strokeDasharray,strokeWidth,opacity,strokeLinecap, etc.).
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(projection = "EqualEarth") |>
viz_path(datum = world, fill = "#f1f3f5") |>
viz_circle(data = world, r = 30, fill = "#38896F") |>
viz_render()