Spatial-aware north arrow

annotation_north_arrow(
  mapping = NULL,
  data = NULL,
  ...,
  height = unit(1.5, "cm"),
  width = unit(1.5, "cm"),
  pad_x = unit(0.25, "cm"),
  pad_y = unit(0.25, "cm"),
  rotation = NULL,
  style = north_arrow_orienteering
)

GeomNorthArrow

Format

An object of class GeomNorthArrow (inherits from Geom, ggproto, gg) of length 5.

Arguments

mapping, data, ...

See Aesthetics

height, width

Height and width of north arrow

pad_x, pad_y

Padding between north arrow and edge of frame

rotation

Override the rotation of the north arrow (degrees conterclockwise)

style

A grob or callable that produces a grob that will be drawn as the north arrow. See north_arrow_orienteering for options.

Value

A ggplot2 layer

Aesthetics

The following can be used as parameters or aesthetics. Using them as aesthetics is useful when facets are used to display multiple panels, and a different (or missing) scale bar is required in different panels. Otherwise, just pass them as arguments to annotation_north_arrow().

  • which_north: "grid" results in a north arrow always pointing up; "true" always points to the north pole from whichever corner of the map the north arrow is in.

  • location: Where to put the scale bar ("tl" for top left, etc.)

Examples


cities <- data.frame(
  x = c(-63.58595, 116.41214),
  y = c(44.64862, 40.19063),
  city = c("Halifax", "Beijing")
)

ggplot(cities) +
  geom_spatial_point(aes(x, y), crs = 4326) +
  annotation_north_arrow(which_north = "true") +
  coord_sf(crs = 3995)


ggplot(cities) +
  geom_spatial_point(aes(x, y), crs = 4326) +
  annotation_north_arrow(which_north = "grid") +
  coord_sf(crs = 3995)