Skip to contents

FWA-Referenced Spatial Hydrology

Stream network-aware spatial operations via direct SQL against fwapg and bcfishpass. Snap points to streams, delineate watersheds, query fish observations, and fetch network-referenced features from the BC Freshwater Atlas.

Installation

pak::pak("NewGraphEnvironment/fresh")

Prerequisites

fresh requires PostgreSQL with the following extensions loaded:

  • fwapg — BC Freshwater Atlas in PostgreSQL
  • bcfishpass — fish passage and habitat modelling
  • bcfishobs — fish observation data

Connection is configured via PG_*_SHARE environment variables (PG_HOST_SHARE, PG_PORT_SHARE, PG_DB_SHARE, PG_USER_SHARE) or passed directly to frs_db_conn().

Example

Query all network features between two points on the same blue line key using watershed code subtraction — no spatial clipping needed:

library(fresh)

result <- frs_network(
  blue_line_key = 360873822,
  downstream_route_measure = 208877,
  upstream_measure = 233564,
  tables = list(
    streams = "whse_basemapping.fwa_stream_networks_sp",
    lakes   = "whse_basemapping.fwa_lakes_poly",
    fish_obs = "bcfishobs.fiss_fish_obsrvtn_events_vw",
    falls   = "bcfishpass.falls_vw"
  )
)

See the subbasin vignette for a full worked example with map output.

Ecosystem

fresh is one piece of a larger watershed analysis workflow:

Package Role
fresh FWA-referenced spatial hydrology (this package)
breaks Delineate sub-basins from break points on stream networks
flooded Delineate floodplain extents from DEMs and stream networks
drift Track land cover change within floodplains over time
fly Estimate airphoto footprints and select optimal coverage for a study area
diggs Interactive explorer for fly airphoto selections (Shiny app)

Pipeline: fresh (network data) → breaks (sub-basins) → flooded (floodplains) → drift (land cover change)

License

MIT