Overview
rfp_source() downloads BC spatial data layers into a
GeoPackage, clipped to one or more watershed groups. Six source types
are available; the authoritative list is
rfp_manifest_types(), of which every value but
frozen is refreshable:
| 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 |
osm |
OpenStreetMap via Overpass | trails and other layers with no provincial source, per
inst/lookups/rfp_source_osm.csv
|
url |
any address ogr2ogr can open |
federal open data, a provincial WFS, per
inst/lookups/rfp_source_url.csv
|
stac |
a STAC catalogue | N items matched by watershed group and item filter, one asset each,
merged into a single layer, per
inst/lookups/rfp_source_stac.csv
|
The three CSV lookups (osm, url,
stac) are defaults.
rfp_source(lookups = ) takes a caller’s own CSV per tier,
merged row-wise over the shipped rows and keyed on
source_layer — so swapping a STAC collection, adding an
epoch or retuning an Overpass selector is a commit in the repo that owns
the config, not an rfp release and a reinstall on every host.
rfp_source_lookup() returns the merged result, with a
lookup_source column naming the file each row came
from.
Basic usage
Download the classic 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():
- Formats watershed group codes for the shell (e.g.,
c("BULK", "KLUM")becomes"'BULK', 'KLUM'") - Locates the shell script and layer list in the installed package via
system.file() - Sets environment variables (
RFP_GPKG,RFP_SOURCES,RFP_TARGETS, …) for the shell script - Calls the script via
system2("bash", ...)
The shell scripts call ogr2ogr, wget and
unzip to download, clip and load layers into the
GeoPackage. The aws pass additionally uses rio
for the lateral-habitat raster; rfp resolves that binary and passes it
in as RFP_RIO, along with RFP_PROJ_LIB scoped
to that one call. Nothing is placed on PATH and
PROJ_LIB is not set globally, so ogr2ogr keeps
using its own PROJ data. Run rfp_check_deps() to see what
resolves on your machine.
Single-layer download (pure R)
For downloading a single BC Data Catalogue layer without Python CLI
tools, use spacehakr::spk_source_bcdata():
spacehakr::spk_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.
The function used to live here as rfp_source_bcdata().
It moved to spacehakr
because fetching a published dataset is not specific to this package,
and sourcing public data is what makes a report’s inputs reproducible
for a reader who does not have this package installed.
rfp_source_bcdata() still works and forwards there, with a
deprecation warning.
