If you are looking for a user-friendly R 📦 for retrieving data from the B.C. Freshwater Atlas please see fwatlasbc 😄. It is built on fwapgr.

fwapgr is an R client for the fwapg pg-featureserv web API used to get data from the B.C. Freshwater Atlas. Data are returned as simple features. Functions and arguments exactly match those available in the API.

Query features from collections:

Get metadata:

Execute spatial functions:

Installation

To install the developmental version from GitHub

# install.packages("remotes")
remotes::install_github("poissonconsulting/fwapgr")

Demonstration

Get Yakoun River stream from ‘whse_basemapping.fwa_stream_networks_sp’ collection:

yakoun <- fwapgr::fwa_collection("whse_basemapping.fwa_stream_networks_sp", filter = list(gnis_name = 'Yakoun River'))
yakoun[c("blue_line_key", "gnis_name", "length_metre")]
#> Simple feature collection with 100 features and 3 fields
#> geometry type:  LINESTRING
#> dimension:      XYZ
#> bbox:           xmin: -132.2789 ymin: 53.38176 xmax: -132.1283 ymax: 53.65705
#> z_range:        zmin: 1 zmax: 92
#> geographic CRS: WGS 84
#> First 10 features:
#>    blue_line_key    gnis_name length_metre                       geometry
#> 1      360881586 Yakoun River    529.95682 LINESTRING Z (-132.1547 53....
#> 2      360881586 Yakoun River    231.06090 LINESTRING Z (-132.2122 53....
#> 3      360881586 Yakoun River    203.93703 LINESTRING Z (-132.1363 53....
#> 4      360881586 Yakoun River    192.11758 LINESTRING Z (-132.275 53.3...
#> 5      360881586 Yakoun River    723.10276 LINESTRING Z (-132.2647 53....
#> 6      360881586 Yakoun River   1807.56714 LINESTRING Z (-132.206 53.6...
#> 7      360881586 Yakoun River    499.69498 LINESTRING Z (-132.204 53.6...
#> 8      360881586 Yakoun River     34.30732 LINESTRING Z (-132.2088 53....
#> 9      360881586 Yakoun River   1618.76222 LINESTRING Z (-132.2093 53....
#> 10     360881586 Yakoun River   2816.01293 LINESTRING Z (-132.2076 53....

Get Yakoun River watershed starting 10km upstream:

wshed <- fwapgr::fwa_watershed_at_measure(unique(yakoun$blue_line_key), downstream_route_measure = 10000)

Use transform argument to simplify polygons. See valid transformation functions here

wshed_simple <- fwapgr::fwa_watershed_at_measure(unique(yakoun$blue_line_key), downstream_route_measure = 10000, transform = c("ST_Simplify", 2000))
ggplot2::ggplot() +
    ggplot2::geom_sf(data = wshed_simple, lwd = 0.15, fill = 'red', alpha = 0.1) +
    ggplot2::geom_sf(data = wshed, lwd = 0.15, fill = 'steelblue', alpha = 0.5) +
  ggplot2::geom_sf(data = yakoun, lwd = 0.15) 

Credit and Inspiration

fwapgr is built on the fwapg pg-featureserv web API hosted and created by Simon Norris at Hillcrest Geographics. It is meant to succeed the fwabc 📦 which retrieved data via WFS with the bcdata 📦.

Many thanks to Simon Norris for his work on fwapg PostgreSQL database and the pg-featureserv web API.

Contribution

Please report any issues.

Pull requests are always welcome.

Code of Conduct

Please note that the fwapgr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.