pd_join_boundaries: Join rows to their boundaries

View source: R/boundaries.R

pd_join_boundariesR Documentation

Join rows to their boundaries

Description

Adds the boundary of the area each row names, by its ABS code, and returns an 'sf' object ready to map. Rows from [pd_rows()] or [pd_aggregate()] carry the codes of the areas their point falls in, such as 'lga_2025_code', and the layer is found from the column's name; any data frame with a column of codes works with 'layer' and 'by'. Aggregate first: a map of 500 council areas is quicker to draw than 80,000 rows each carrying its area's shape.

Usage

pd_join_boundaries(x, layer = NULL, by = NULL, cache = NULL)

Arguments

x

A data frame.

layer

The layer to join to, as for [pd_boundaries()]. Found from the column names of 'x' when 'NULL'.

by

The column of ‘x' that holds the codes. The layer’s code field, such as '"lga_2025_code"', when 'NULL'. Numeric codes are compared as text, with leading zeros restored, so postcode 800 matches '"0800"'.

cache

Keep the file in [pd_cache_dir()] and reuse it next time. Versions never change, so a kept file never goes stale. Off unless 'options(publicdataau.cache = TRUE)' is set.

Value

An 'sf' tibble with the rows of ‘x' in their order, the area’s name when ‘x' lacks it, and the area’s geometry. A row whose code matches no area has an empty geometry, and a message says how many.

See Also

Other maps: pd_boundaries(), pd_boundary_layers(), pd_sf()

Examples


# Downloads the SA2 boundaries, tens of megabytes, so this runs only when asked.
by_sa2 <- pd_aggregate("act-road-crashes", group = "sa2_2021_code")
map <- pd_join_boundaries(by_sa2)
plot(map["count"])


publicdataau documentation built on Oct. 14, 2026, 5:07 p.m.