Skip to contents

Small multiples of one choropleth, drawn once per projection, so the cost of a projection choice is visible rather than asserted. The data and the classification are held fixed; only the CRS varies.

Usage

projection_compare(
  data,
  fill,
  projections = c("equal_earth", "robinson", "winkel_tripel", "mercator"),
  ncol = NULL,
  labeller = c("name", "property"),
  ...,
  projection = NULL
)

Arguments

data

An sf map-ready frame (projections are an sf-backend feature; the polygon backend draws in coord_quickmap() and cannot reproject).

fill

The fill column (unquoted).

projections

Projections to compare (default: Equal Earth, Robinson, Winkel tripel and Mercator – an equal-area, two compromises and a conformal). See projection_info().

ncol

Number of facet columns.

labeller

"name" (default) labels each panel with the projection name; "property" appends what it preserves, which is the point of the comparison.

...

Passed to world_map() (e.g. style, palette, n_bins).

projection

Not an argument of this function. It exists only to catch the singular spelling, which R's partial matching would otherwise bind to projections – drawing a single panel from a function whose purpose is several. Passing it is an error; use projections.

Value

A faceted ggplot object.

Examples

# \donttest{
if (requireNamespace("sf", quietly = TRUE) &&
    requireNamespace("rnaturalearth", quietly = TRUE)) {
  attach_geometry(countryatlas::world_snapshot$countries, geometry = "sf") |>
    projection_compare(gdp_per_capita, style = "quantile")
}

# }