Package 'nswgeo'

Title: Geospatial Data and Maps for New South Wales, Australia
Description: Geospatial data for creating maps of New South Wales (NSW), Australia, and some helpers to work with common problems like normalising postcodes. Registers its data with 'cartographer'.
Authors: Carl Suster [aut, cre] , Western Sydney Local Health District, NSW Health [cph]
Maintainer: Carl Suster <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0.9000
Built: 2024-10-27 05:50:31 UTC
Source: https://github.com/cidm-ph/nswgeo

Help Index


Geospatial Tools for New South Wales

Description

This package contains geospatial data for the NSW border and several types of features. It also contains some map plotting helpers to help you get from a data frame to a plot for common scenarios.

Author(s)

Maintainer: Carl Suster [email protected] (ORCID)

Other contributors:

  • Western Sydney Local Health District, NSW Health [copyright holder]

See Also

Useful links:


Geospatial data of the Australian state and territory administrative boundaries.

Description

Excludes external territories.

Usage

australia

states

Format

An object of class sfc_MULTIPOLYGON (inherits from sfc) of length 1.

An object of class sf (inherits from tbl_df, tbl, data.frame) with 8 rows and 9 columns.

Details

The geometries have been simplified with a tolerance of 5 km to reduce the level of detail.

Functions

  • australia: External boundaries of Australia as a multipolygon.

  • states: State and internal territory boundaries of Australia.

Source

Australian Bureau of Statistics. "Australian Statistical Geography Standard (ASGS) Edition 3." ABS, Jul2021-Jun2026, https://www.abs.gov.au/statistics/standards/australian-statistical-geography-standard-asgs-edition-3/jul2021-jun2026, accessed 10 November 2022.

The original dataset is published under the Creative Commons Attribution 4.0 International licence, © Commonwealth of Australia 2021.

Examples

library(ggplot2)
ggplot(states) + geom_sf(aes(fill = STE_NAME21))

Small sample of COVID-19 cases in NSW for testing and demonstration.

Description

This subset covers a random selection of entries from 3 LGAs, and ignores the case count field.

Usage

covid_cases_nsw

Format

A data frame with 100 rows and the following columns:

postcode

The postal code

lhd

The name of the Local Health District

lga

The name of the Local Government Area

type

A synthetic disease type/lineage/etc., either A or B

year

Year of the case notification

Source

NSW Ministry of Health. "NSW COVID-19 cases by location." https://data.nsw.gov.au/data/dataset/covid-19-cases-by-location, accessed 11 October 2022.

The original dataset is published under the Creative Commons Attribution 4.0 licence, © State of New South Wales 2020-2022.

Examples

head(covid_cases_nsw)

Coordinate reference system for Australia

Description

GDA2020 is the official CRS used by the Commonwealth and NSW. Geospatial data in this package uses GDA2020.

Usage

crs_gda2020()

crs_gda2020_cartesian()

crs_gda2020_albers()

Details

crs_gda2020 is EPSG 7844 with axes specified in degrees. crs_gda2020_cartesian is EPSG 7842 with Cartesian axes in metres. crs_gda2020_albers is EPSG 9473, the Albers equal area projection used for area computation.

Value

A simple features CRS


Geospatial data of the New South Wales administrative boundaries.

Description

These include the Unincorporated Far West Region. lga_nsw excludes Jervis Bay Territory and the ACT. poa_nsw includes both territories and some postal areas extend past the state boundary.

Usage

lga_nsw

poa_nsw

Format

An object of class sf (inherits from tbl_df, tbl, data.frame) with 131 rows and 9 columns.

An object of class sf (inherits from tbl_df, tbl, data.frame) with 644 rows and 7 columns.

Details

The geometries have been simplified with a tolerance of 750 m to reduce the level of detail.

Functions

  • lga_nsw: Local Government Area boundaries of New South Wales.

  • poa_nsw: Postal area boundaries of New South Wales.

Source

Australian Bureau of Statistics. "Australian Statistical Geography Standard (ASGS) Edition 3." ABS, Jul2021-Jun2026 (24 July 2024 update), https://www.abs.gov.au/statistics/standards/australian-statistical-geography-standard-asgs-edition-3/jul2021-jun2026, accessed 29 July 2024.

The original dataset is published under the Creative Commons Attribution 4.0 International licence, © Commonwealth of Australia 2021.

Examples

library(ggplot2)
ggplot(lga_nsw) + geom_sf(aes(fill = LGA_NAME_2024), show.legend = FALSE)

library(sf)
sf_use_s2(FALSE)
# cut out part of the postcode dataset (it's quite large)
bbox <- st_bbox(c(xmin = 142, xmax = 147, ymin = -33, ymax = -30)) |>
 st_as_sfc(crs = crs_gda2020())
st_crop(poa_nsw, bbox) |>
  ggplot() +
  geom_sf() +
  geom_sf_text(aes(label = POA_CODE_2021), size = 4)

Local Health Districts of NSW.

Description

The geometries have been simplified with a tolerance of 750 m to reduce the level of detail.

Usage

lhd

Format

An object of class sf (inherits from tbl_df, tbl, data.frame) with 15 rows and 11 columns.

Source

Spatial Services, Department of Customer Service NSW. "MyHospitals_Public", https://portal.spatial.nsw.gov.au/portal/home/item.html?id=5a1e5dd9b38245d3b976c21b56fd6185, accessed 4 May 2023. Republished from NSW Ministry of Health, "Map of local health districts", https://www.health.nsw.gov.au/lhd/Pages/lhd-maps.aspx.

The original dataset is published under the Creative Commons Attribution 4.0 International licence, © State of New South Wales NSW Ministry of Health 2023. For current information go to https://www.health.nsw.gov.au.

Examples

library(ggplot2)
ggplot(lhd) + geom_sf(aes(fill = lhd_name), show.legend = FALSE)

Normalise postal codes

Description

Some special postcodes are used in addresses, such as codes for post office boxes. This helper converts those to the postcode for the closest normal suburb if there is a reasonable clear match. If there is no good match, the postcodes are left unchanged.

Usage

normalise_postcodes(codes)

Arguments

codes

Character vector of postcodes (or coercible to one).

Details

Note that this goes a little further than the aliases that are registered with cartographer (which only account for postcodes with no geospatial data in the ABS dataset).

Value

Character vector of the same size as the input, but with the normalised postcodes.

Examples

normalise_postcodes(c(1685, 2000, 1010, 2129, 2145))

Normalise state names from abbreviations

Description

Expand abbreviations like "NSW" to "New South Wales", and normalise to title capitalisation. Entries that don't match any state name or abbreviation are left untouched.

Usage

normalise_state_names(names)

Arguments

names

Character vector of state names.

Value

Vector of the same size as the input, but with the normalised state names.

Examples

normalise_state_names(c("nsw", "VIC", "overseas", "Queensland"))

Outlines of New South Wales and relevant territories.

Description

Lord Howe Island is administratively part of NSW, but as it is a small island some 600 km off the coast, it is frequently omitted from maps of NSW.

Usage

nsw

act

lhi

jbt

sydney

Format

An object of class sfc_MULTIPOLYGON (inherits from sfc) of length 1.

An object of class sfc_MULTIPOLYGON (inherits from sfc) of length 1.

An object of class sfc_MULTIPOLYGON (inherits from sfc) of length 1.

An object of class sfc_MULTIPOLYGON (inherits from sfc) of length 1.

An object of class sfc_POLYGON (inherits from sfc) of length 1.

Details

The Australian Capital Territory is an enclave within NSW, and Jervis Bay Territory is a small Australian territory on the coast, surrounded by NSW. Neither are NSW territory, but they affect the shape of NSW's outline and are sometimes useful to include in maps alongside NSW due to their locations.

The geometry for nsw has been simplified with a tolerance of 750 m to reduce the level of detail, whereas the territories maintain their full resolution. sydney is simplified with a 500 m tolerance.

Functions

  • nsw: External state boundary excluding LHI but including ACT and JBT.

  • act: Australian Capital Territory boundary.

  • lhi: Lord Howe Island boundary.

  • jbt: Jervis Bay Territory boundary.

  • sydney: Greater Sydney boundary.

Source

Australian Bureau of Statistics. "Australian Statistical Geography Standard (ASGS) Edition 3." ABS, Jul2021-Jun2026 (24 July 2024 update), https://www.abs.gov.au/statistics/standards/australian-statistical-geography-standard-asgs-edition-3/jul2021-jun2026, accessed 29 July 2024.

The original dataset is published under the Creative Commons Attribution 4.0 International licence, © Commonwealth of Australia 2021.

See Also

outline()


New South Wales outline with or without related territories

Description

The default outline nswgeo::nsw includes Jervis Bay Territory, excludes Lord Howe Island, and does not have a cut out for the ACT. This utility allows each of these to be adjusted.

Usage

outline(lord_howe_island = FALSE, act_cutout = FALSE, jervis_bay = TRUE)

Arguments

lord_howe_island

Include Lord Howe Island.

act_cutout

Cut out the area of the Australian Capital Territory.

jervis_bay

Cover the area of the Jervis Bay Territory.

Value

A simple features data frame with the requested geometries.

See Also

nsw

Examples

library(ggplot2)

outline(lord_howe_island = TRUE) |> ggplot() + geom_sf()

Primary Health Network boundaries of New South Wales

Description

The geometries have been simplified with a tolerance of 500 m to reduce the level of detail.

Usage

phn

Format

An object of class sf (inherits from tbl_df, tbl, data.frame) with 10 rows and 9 columns.

Source

National Recovery and Resilience Agency, "PHN Boundaries used by the NBRA", https://data.gov.au/data/dataset/phn-boundaries-used-by-the-nbra, accessed 25 May 2023.

The original dataset is published under the Creative Commons Attribution 2.5 Australia licence, © Commonwealth of Australia 2021.


Concordance between postal areas and local health districts.

Description

Contains the other administrative geometries which intersect with the local health district boundaries, along with the size of the intersection.

Usage

poa_lhd_concordance

Format

An object of class data.frame with 825 rows and 5 columns.

Details

For geographic regions used by the Australian Bureau of Statistics (ABS), the ABS publishes correspondence files. These files compare how two different types of regions align with each other. The Australian Government Department of Health and Aged Care published analogous concordance files for primary health networks (PHNs). These are useful for mapping between different types of administrative districts. There does not appear to be a publicly available set of concordance files for New South Wales local health district geographies.

The concordance was computed here by intersecting the ABS geometries with the local health district geometries. The fraction of the ABS geometry's area included in the intersection is reported in the column FRAC_INCLUDED. Any intersection with FRAC_INCLUDED at least 0.01% was retained. Area computations were performed in crs_gda2020_albers() (EPSG 9473 equal area Albers) coordinates at the original reolution of the source data.

Note that postal areas are not precisely the same as postcodes used by Australia Post, however they are very similar.

Source

Computed using the same source datasets as lhd and poa_nsw.

Examples

library(dplyr)

# postcodes that overlap with Murrumbidgee LHD
poa_lhd_concordance |>
  filter(lhd_name == "Murrumbidgee", FRAC_INCLUDED > 0.005) |>
  arrange(desc(FRAC_INCLUDED)) |>
  pull(POA_NAME_2021)

Postal codes and localities of New South Wales.

Description

Derived from several government sources with some community curation. This version additionally attempts to canonicalise non-physical postcodes to assist with mapping.

Usage

postcodes

Format

A data frame with 7 columns:

postcode

A postal code

locality

A suburb or locality

state

NSW

SA2_NAME_2016

Statistical Area 2 name to assist with disambiguating localities with identical names

special

Flag indicating this is a post office box, mail distribution centre or other special postal code

old

Flag indicating that this code appears to have been superseded

canonical

The closest canonical postal code, e.g. mapping post office boxes to the main suburb's postal code

Source

Matthew Proctor. "Australian Postcodes", https://www.matthewproctor.com/australian_postcodes, accessed 6 February 2023.

The original dataset is released to the public domain.

Examples

set.seed(12345)
postcodes[sort(sample.int(nrow(postcodes), 5)),]

Suburbs of New South Wales.

Description

A dataset containing the names of suburbs in NSW and their postcodes. These fields are extracted as-is from the source dataset published by DCS Spatial Services, NSW Government.

Usage

suburbs

Format

A data frame with 2 columns:

suburbname

The name of the suburb, in upper case

postcode

The main postcode of the suburb, as a character

Source

Spatial Services, Department of Customer Service NSW. "NSW Administrative Boundaries Theme - Suburb." https://portal.spatial.nsw.gov.au/portal/home/item.html?id=38bdaa10b7cc41a3a19be6eca91f5368, accessed 21 September 2022.

The original dataset is published under the Creative Commons Attribution 4.0 International licence, © State of New South Wales (Spatial Services, a business unit of the Department of Customer Service NSW).