fwapgr
is an R package that uses the fwapg
API to query the
Freshwater
Atlas
(FWA) of British Columbia (BC). The functions and arguments in fwapgr
match those available in the API.
If you are looking for a higher-level R package to query the FWA of BC
see fwatlasbc
which
wraps fwapgr
.
To install the lastest version from GitHub
# install.packages("devtools")
devtools::install_github("poissonconsulting/pgfeatureserv")
devtools::install_github("poissonconsulting/fwapgr")
fwapgr
allows you to perform three types of operation.
Get information about the collections or a collection’s properties:
Query features from a collection:
Execute spatial functions:
fwa_index_point()
fwa_locate_along()
fwa_locate_along_interval()
fwa_watershed_at_measure()
fwa_watershed_hex()
fwa_watershed_stream()
hydroshed()
Get Sangan River from whse_basemapping.fwa_stream_networks_sp
collection:
coll <- "whse_basemapping.fwa_stream_networks_sp"
river <- fwapgr::fwa_query_collection(coll, filter = list(gnis_name = "Sangan River"))
river
#> Simple feature collection with 21 features and 26 fields
#> Geometry type: LINESTRING
#> Dimension: XYZ
#> Bounding box: xmin: -131.9972 ymin: 53.94994 xmax: -131.9168 ymax: 54.0332
#> z_range: zmin: 1 zmax: 67
#> Geodetic CRS: WGS 84
#> # A data frame: 21 × 27
#> blue_line_key blue_line_key_50k downstream_route_mea…¹ edge_type feature_code
#> * <int> <int> <dbl> <dbl> <chr>
#> 1 360879896 11 6808. 1000 GA24850000
#> 2 360879896 11 12161. 1000 GA24850000
#> 3 360879896 11 9544. 1000 GA24850000
#> 4 360879896 11 10909. 1000 GA24850000
#> 5 360879896 11 1266. 1000 GA24850000
#> 6 360879896 11 13068. 1000 GA24850000
#> 7 360879896 11 8744. 1000 GA24850000
#> 8 360879896 11 13776. 1000 GA24850000
#> 9 360879896 11 7849. 1000 GA24850000
#> 10 360879896 11 5029. 1000 GA24850000
#> # ℹ 11 more rows
#> # ℹ abbreviated name: ¹downstream_route_measure
#> # ℹ 22 more variables: feature_source <chr>, fwa_watershed_code <chr>,
#> # gnis_id <int>, gnis_name <chr>, gradient <dbl>, left_right_tributary <chr>,
#> # length_metre <dbl>, linear_feature_id <int>, local_watershed_code <chr>,
#> # localcode_ltree <chr>, stream_magnitude <dbl>, stream_order <dbl>,
#> # upstream_route_measure <dbl>, waterbody_key <chr>, …
Get simplified Yakoun River watershed starting 10km upstream:
blk <- river$blue_line_key[1]
wshed <- fwapgr::fwa_watershed_at_measure(
blk,
downstream_route_measure = 10000,
transform = c("ST_Simplify", 2000)
)
ggplot2::ggplot() +
ggplot2::geom_sf(data = wshed, lwd = 0.15, fill = "steelblue", alpha = 0.5) +
ggplot2::geom_sf(data = river, lwd = 0.15)
fwapgr
relies on fwapg
API which is created,
maintained and hosted by Simon
Norris at Hillcrest
Geographics.
Please report any issues.
Pull requests are always welcome.
Please note that fwapgr
is released with a Contributor Code of
Conduct.
By contributing to this project, you agree to abide by its terms.