pgfeatureserv
is an R client for pg_featureserv, a RESTful web service that provides access to spatial data stored in PostGIS tables, as well as spatial processing capability based on PostGIS spatial functions.
For more information on pg_featureserv:
- User Guide
- API Summary
- Github Page
Get information about collections or a single collection:
pgf_collections()
pgf_collection_properties()
pgf_collection_description()
pgf_collection_crs()
pgf_collection_bbox()
pgf_collection_geometry_type()
Query features or a single feature from a collection:
Get information about functions or a single function:
Execute a spatial function and get result:
You can install the development version of pgfeatureserv from GitHub with:
# install.packages("devtools")
devtools::install_github("poissonconsulting/pgfeatureserv")
Lookup available collections in BC Freshwater Atlas:
base_url <- "https://features.hillcrestgeo.ca/"
path <- "fwa"
collections <- pgfeatureserv::pgf_collections(base_url = base_url, path = path)
collections$id
#> [1] "hydrosheds.hybas_lev12_v1c"
#> [2] "usgs.wbdhu12"
#> [3] "whse_basemapping.fwa_approx_borders"
#> [4] "whse_basemapping.fwa_assessment_watersheds_poly"
#> [5] "whse_basemapping.fwa_basins_poly"
#> [6] "whse_basemapping.fwa_bays_and_channels_poly"
#> [7] "whse_basemapping.fwa_bcboundary"
#> [8] "whse_basemapping.fwa_coastlines_sp"
#> [9] "whse_basemapping.fwa_glaciers_poly"
#> [10] "whse_basemapping.fwa_islands_poly"
#> [11] "whse_basemapping.fwa_lakes_poly"
#> [12] "whse_basemapping.fwa_linear_boundaries_sp"
#> [13] "whse_basemapping.fwa_manmade_waterbodies_poly"
#> [14] "whse_basemapping.fwa_named_streams"
#> [15] "whse_basemapping.fwa_named_watersheds_poly"
#> [16] "whse_basemapping.fwa_obstructions_sp"
#> [17] "whse_basemapping.fwa_rivers_poly"
#> [18] "whse_basemapping.fwa_stream_networks_sp"
#> [19] "whse_basemapping.fwa_streams_vw"
#> [20] "whse_basemapping.fwa_watershed_groups_poly"
#> [21] "whse_basemapping.fwa_watersheds_poly"
#> [22] "whse_basemapping.fwa_wetlands_poly"
Get Sangan River from the stream network collection:
coll <- "whse_basemapping.fwa_stream_networks_sp"
river <- pgfeatureserv::pgf_collection_features(coll, base_url = base_url, path = path,
filter = list(gnis_name = "Sangan River"))
class(river)
#> [1] "sf" "tbl" "tbl_df" "data.frame"
river[1:5, 1:4]
#> # A data frame: 5 × 4
#> blue_line_key blue_line_key_50k downstream_route_measure edge_type
#> <dbl> <dbl> <dbl> <dbl>
#> 1 360879896 130 16588. 1000
#> 2 360879896 11 1266. 1000
#> 3 360879896 130 17516. 1050
#> 4 360879896 11 13068. 1000
#> 5 360879896 11 6808. 1000
Please note that the pgfeatureserv project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.