Skip to contents

Downloads a layer from the BC Data Catalogue, optionally intersects with a mask, and writes it to a GeoPackage.

Usage

rfp_source_bcdata(
  bcdata_record_id = NULL,
  path_gpkg = NULL,
  mask = NULL,
  layer_name = NULL
)

Arguments

bcdata_record_id

character A character string specifying the BC Data Catalogue record ID permanent id (7ecfafa6-5e18-48cd-8d9b-eae5b5ea2881), name of the record (pscis-assessments) or object name (ex. WHSE_FISH.PSCIS_ASSESSMENT_SVW). The name of the record can be found at https://catalogue.data.gov.bc.ca/. This does not need to be in capitals as we will convert to capitals within the function.

path_gpkg

character Path to the output GeoPackage file.

mask

sf::sf Optional masking polygon to clip spatial extent. Can massively increase download speed as first queries only bbox from api.

layer_name

character Optional layer name for writing to the GPKG. If NULL - the name of the layer defaults to bcdata_record_id as all lower case. Designed to work best with object name fed to bcdata_record_id.

Examples

if (FALSE) { # \dontrun{
path_gpkg <- "~/Projects/gis/restoration_wedzin_kwa/background_layers.gpkg"
mask <- sf::st_read(
  path_gpkg,
  layer = "whse_basemapping.fwa_watershed_groups_poly"
)
get_this <- c("whse_basemapping.bcgs_5k_grid", "WHSE_BASEMAPPING.BCGS_2500_GRID")
name_this <- c("test", "test2")
purrr::walk2(
  .x = get_this,
  .y = name_this,
  .f = ~rfp_source_bcdata(
    bcdata_record_id = .x,
    path_gpkg = path_gpkg,
    layer_name = .y,
    mask = mask
  )
)
} # }