Skip to contents

Functions to read and share subunit data. Subunits are the lowest level in the spatial hierarchy: regions -> DAU -> GMU -> subunits.

Usage

lkup_read_subunit(
  id = NULL,
  dau_id = NULL,
  gmu_id = NULL,
  name = NULL,
  includes = NULL,
  pages = list(omit = 1),
  ...
)

lkup_read_subunit_sf(
  id = NULL,
  dau_id = NULL,
  gmu_id = NULL,
  name = NULL,
  geometry = c("polygon", "point"),
  includes = NULL,
  pages = list(omit = 1),
  ...
)

lkup_share_subunit(
  format = c("csv", "json", "parquet"),
  id = NULL,
  dau_id = NULL,
  gmu_id = NULL,
  name = NULL,
  geometry = c("none", "polygon", "point"),
  includes = NULL,
  pages = list(omit = 1),
  ...
)

Arguments

id

integer, id of the record to retrieve

dau_id

integer, filter to a particular analysis unit (DAU)

gmu_id

integer, filter to a particular management unit (GMU)

name

character, filter by subunit name

includes

character vector of related resources to include

pages

list of pagination arguments (size, number, omit)

...

additional filters to include in the query

geometry

character, type of geometry ("polygon" or "point") for spatial data

format

character, format for sharing ("csv", "json", "parquet")

Value

lkup_read_subunit() returns a tibble with columns: id, management_unit_id, name, sort_order. Additional columns may appear when includes is specified.

lkup_read_subunit_sf() returns an sf object with the same columns plus a geometry column (WGS84, EPSG:4326). Geometry type is POLYGON or MULTIPOLYGON when geometry = "polygon", POINT when geometry = "point".

lkup_share_subunit() returns a single character string: a temporary authenticated URL for downloading the data.

Details

Subunits represent the smallest spatial aggregation in the hierarchy. They often serve as the sampling unit in surveys.

Spatial data is returned in WGS84 (EPSG:4326) projection.

When sharing spatial data, the format must be "json". This ensures valid GeoJSON output that can be read by GIS software.

Valid includes:

  • managementUnit

Examples

if (FALSE) { # \dontrun{
# Basic read
lkup_read_subunit()
lkup_read_subunit(name = "North")

# Spatial reads
lkup_read_subunit_sf()  # defaults to polygons
lkup_read_subunit_sf(geometry = "point")

# Share data
lkup_share_subunit(format = "csv")
# For spatial data
lkup_share_subunit(format = "json", geometry = "polygon")
} # }