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 <Carl.Suster@health.nsw.gov.au>
License: MIT + file LICENSE
Version: 0.3.3.9000
Built: 2023-11-23 06:25:48 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 Carl.Suster@health.nsw.gov.au (ORCID)

Other contributors:

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

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()

Value

A simple features CRS


Local Health Districts of NSW.

Description

The geometries have been simplified with a tolerance of 1 km 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=78df4a3e987b4e7e8b241ee5bfeee358, 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"))

Geospatial data of the New South Wales administrative boundaries.

Description

Excludes the borders with the ACT and Jervis Bay Territory, and Lord Howe Island.

Usage

nsw

lga_nsw

poa_nsw

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 131 rows and 9 columns.

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

Details

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

Functions

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 27 September 2022.

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_2021), 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)

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.


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).