Skip to contents

Produces a ggplot2 map for rapid exploratory visualisation. Returns a ggplot object that can be extended with standard ggplot2 layers.

Usage

pk_map(x, fill = NULL, title = NULL, ...)

Arguments

x

An sf object.

fill

Character. Column name to use as fill variable. NULL (default) produces an outline map.

title

Character. Map title. NULL for no title.

...

Additional arguments passed to ggplot2::geom_sf().

Value

Returns a ggplot object (class "gg" and "ggplot") representing a choropleth map.

When fill = NULL, the output is an outline map with grey90 fill and white borders, useful for context or reference.

When a fill variable is provided, the output uses a viridis color scale with automatic legend, for visualizing spatial distributions of continuous variables (e.g., area, population, density).

The returned ggplot object can be extended with additional layers, themes, or scales using standard ggplot2 syntax.

Examples

# Outline map of provinces
pk_map(get_provinces())


# Choropleth map with fill variable
pk_map(get_provinces(), fill = "area_km2", title = "Province areas")