Skip to contents

The viz_halfcircle function draws rotatable half-circles on the map from a spatial data frame or from a single position. It can be used to represent values with semi-circular proportional symbols.

Usage

viz_halfcircle(
  map,
  data = NULL,
  id = NULL,
  pos = c(0, 0),
  dx = 0,
  dy = 0,
  angle = 0,
  r = 10,
  innerRadius = 0,
  cornerRadius = 2,
  k = 50,
  fixmax = NULL,
  sort = NULL,
  descending = NULL,
  coords = "geo",
  fill = NULL,
  stroke = NULL,
  tip = FALSE,
  ...
)

Arguments

map

A geoviz map created with viz_create.

data

object. Optional. A spatial data frame.

id

character. Optional. Unique layer id.

pos

numeric vector. Optional. Position of a single half-circle (default c(0, 0)).

dx

numeric. Optional. Horizontal shift (default 0).

dy

numeric. Optional. Vertical shift (default 0).

angle

numeric. Optional. Rotation angle in degrees (default 0).

r

numeric or character. Optional. Outer radius (default 10). Can be a fixed value or the name of a field containing numerical values.

innerRadius

numeric. Optional. Inner radius (default 0).

cornerRadius

numeric. Optional. Corner radius (default 2).

k

numeric. Optional. Radius of the largest half-circle (default 50).

fixmax

numeric. Optional. Value corresponding to the half-circle of radius k. Useful to ensure comparability between maps.

sort

character or function. Optional. Field name or function to sort half-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.

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_halfcircle(data = world, r = 30, fill = "#38896F") |>
viz_render()