Skip to contents

Overview

rfp_source() downloads BC spatial data layers into a GeoPackage, clipped to one or more watershed groups. Three source types are available:

Type Source What you get
bcdata BC Data Catalogue PSCIS crossings, Indian reserves, BC regions, and layers listed in inst/lookups/rfp_source_bcdata.txt
fwa Hillcrest Geo FWA feature service Freshwater Atlas named streams, watersheds
aws NewGraph S3 bucket bcfishpass crossings/streams, transport, cadastre, lateral habitat raster, model parameters

Basic usage

Download all three source types for a watershed group:

library(rfp)

rfp_source("bcdata", c("ADMS"))
rfp_source("fwa", c("ADMS"))
rfp_source("aws", c("ADMS"))

Each call appends layers to background_layers.gpkg in the current working directory. The aws type also produces habitat_lateral.tif.

Multiple watershed groups

Pass a character vector with multiple codes:

rfp_source("bcdata", c("BULK", "KLUM"))

Custom output path

rfp_source("bcdata", c("ELKR"), path_gpkg = "my_project.gpkg")

Configuring which layers to download

Layer lists are text files in inst/lookups/. Each line is a layer name. Lines starting with # are disabled:

# Active layers (uncommented)
whse_fish.pscis_assessment_svw
reg_legal_and_admin_boundaries.qsoi_bc_regions

# Disabled layers (commented out)
#whse_basemapping.bcgs_20k_grid
#whse_forest_vegetation.bec_biogeoclimatic_poly

To customise, copy the text file from inst/lookups/ to your project directory and edit it.

How it works

Under the hood, rfp_source():

  1. Formats watershed group codes for the shell (e.g., c("BULK", "KLUM") becomes "'BULK', 'KLUM'")
  2. Locates the shell script and layer list in the installed package via system.file()
  3. Sets environment variables (RFP_GPKG, RFP_SOURCES, PROJ_LIB) for the shell script
  4. Calls the script via system2("bash", ...) with the uv venv on PATH

The shell scripts call bcdata, ogr2ogr, fio, and rio to download, clip, and load layers into the GeoPackage.

Single-layer download (pure R)

For downloading a single BC Data Catalogue layer without Python CLI tools, use rfp_source_bcdata():

rfp_source_bcdata(
  bcdata_record_id = "whse_fish.pscis_assessment_svw",
  path_gpkg = "background_layers.gpkg",
  mask = my_aoi_polygon
)

This uses the bcdata R package directly — no shell scripts, no Python.