Package 'fwapgr'

Title: Client for BC Freshwater Atlas fwapg API
Description: Client for fwapg, a PostgreSQL database and web API for BC Freshwater Atlas data.
Authors: Sebastian Dalgarno [aut, cre] , Joe Thorley [aut] , Poisson Consulting [cph, fnd], Nadine Hussein [ctb]
Maintainer: Sebastian Dalgarno <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9015
Built: 2024-09-17 19:14:01 UTC
Source: https://github.com/poissonconsulting/fwapgr

Help Index


Query Freshwater Atlas Collection

Description

Query a collection from the freshwater atlas.

Usage

fwa_collection(
  collection_id,
  filter = NULL,
  limit = 10000,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

fwa_query_collection(
  collection_id,
  filter = NULL,
  limit = 10000,
  offset = 0,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  sortby = NULL,
  groupby = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

collection_id

A character string of the collection id.

filter

A named vector or list of the filter(s) to apply, where the list names correspond to column names and the list values correspond to the desired value, e.g. list(gnis_name = "Sangan River").

limit

A positive whole number indicating the maximum number of features to return.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

offset

A positive whole number indicating the offset of start of returned results.

sortby

A string that sorts the response items by a property. Default is ascending but property name can be prepended with '-' to indicate descending.

groupby

A string of the property name (i.e., column name) to group response features by. This would typically be used with an aggregate transform function.

Value

An sf object.

Functions

  • fwa_collection(): Query Freshwater Atlas Collection

    [Soft-deprecated]

See Also

Other collections: fwa_collection_properties(), fwa_collections()

Examples

collection_id <- "whse_basemapping.fwa_approx_borders"
filter <- list(border = "USA_49")
fwa_query_collection(collection_id, filter = filter)

collection_id <- "whse_basemapping.fwa_stream_networks_sp"
filter <- list(gnis_name = "Sangan River")
fwa_query_collection(collection_id, filter = filter)

Freshwater Atlas Collection's Properties

Description

Get information about a collection's column names.

Usage

fwa_collection_properties(
  collection_id,
  nocache = getOption("fwa.nocache", FALSE)
)

fwa_meta_properties(collection_id, nocache = getOption("fwa.nocache", FALSE))

Arguments

collection_id

A character string of the collection id.

nocache

A flag specifying whether or not to cache results.

Value

A tibble.

Functions

  • fwa_meta_properties(): Freshwater Atlas Collection's Properties

    [Soft-deprecated]

See Also

Other collections: fwa_collection(), fwa_collections()

Examples

fwa_collection_properties("whse_basemapping.fwa_stream_networks_sp")

Freshwater Atlas Collections

Description

Get information about the collections.

Usage

fwa_collections(nocache = getOption("fwa.nocache", FALSE))

fwa_meta_collections(nocache = getOption("fwa.nocache", FALSE))

Arguments

nocache

A flag specifying whether or not to cache results.

Value

A tibble.

Functions

  • fwa_meta_collections(): Freshwater Atlas Collections

    [Soft-deprecated]

See Also

Other collections: fwa_collection(), fwa_collection_properties()

Examples

fwa_collections()

Freshwater Atlas Index Point

Description

Gets the nearest point on a stream as the crow flies to the coordinates (within the tolerance).

Usage

fwa_index_point(
  x,
  y,
  srid = 4326,
  tolerance = 5000,
  limit = 1,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

x

A number of the x coordinate.

y

A number of the y coordinate.

srid

A positive whole number of the epsg of the coordinates.

tolerance

A number of the tolerance in m.

limit

A positive whole number indicating the maximum number of features to return.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Details

To also return the second nearest point on a stream as the crow flies (within the tolerance) set limit = 2.

Value

An sf object.

See Also

API documentation

Other functions: fwa_locate_along(), fwa_locate_along_interval(), fwa_watershed_at_measure(), fwa_watershed_hex(), fwa_watershed_stream(), hydroshed()

Examples

fwa_index_point(x = -132.26, y = 53.36)

Freshwater Atlas Locate Along

Description

Gets the point on a stream corresponding to the river metre (downstream route measure).

Usage

fwa_locate_along(
  blue_line_key,
  downstream_route_measure = 0,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

blue_line_key

A positive whole number of the stream blue line key.

downstream_route_measure

A positive number of the river metre.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Value

An sf object.

See Also

API documentation

Other functions: fwa_index_point(), fwa_locate_along_interval(), fwa_watershed_at_measure(), fwa_watershed_hex(), fwa_watershed_stream(), hydroshed()

Examples

fwa_locate_along(356308001, downstream_route_measure = 10000)

Freshwater Atlas Locate Along Interval

Description

Gets a regularly spaced set of points between two river metres.

Usage

fwa_locate_along_interval(
  blue_line_key,
  interval_length = 100,
  start_measure = 0,
  end_measure = NULL,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

blue_line_key

A positive whole number of the stream blue line key.

interval_length

An integer of the interval distance in meters.

start_measure

An integer of the distance in meters upstream from the river mouth to start from.

end_measure

An integer of the distance in meters upstream from the river mouth to end at.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Value

An sf object.

See Also

API documentation

Other functions: fwa_index_point(), fwa_locate_along(), fwa_watershed_at_measure(), fwa_watershed_hex(), fwa_watershed_stream(), hydroshed()

Examples

fwa_locate_along_interval(356308001, interval_length = 10, start_measure = 0)

Freshwater Atlas Watershed at Downstream Route Measure

Description

Gets a polygon of the watershed at a specified river metre.

Usage

fwa_watershed_at_measure(
  blue_line_key,
  downstream_route_measure = 0,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

blue_line_key

A positive whole number of the stream blue line key.

downstream_route_measure

A positive number of the river metre.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Details

The function selects and aggregate all the fundamental watershed polygons upstream of the fundamental watershed in which the point lies.

Depending on where the point is in the fundamental watershed one of four things can happen to the fundamental watershed.

  1. If the point is < 50 m upstream from the bottom of the fundamental watershed then the fundamental watershed is included in the aggregation (recorded as KEEP in the refine_method property).

  2. Else if the point is < 100m downstream from the top of the fundamental watershed then the fundamental watershed is not included in the aggregation (recorded as DROP in the refine_method property).

  3. Else if the point is on a polygonal river/canal the fundamental watershed is cut across the banks of the river before being included in the aggregation (recorded as CUT in the refine_method property).

  4. Otherwise something else happens (recorded as DEM in the refine_method property).

Value

An sf object.

See Also

API documentation

Other functions: fwa_index_point(), fwa_locate_along(), fwa_locate_along_interval(), fwa_watershed_hex(), fwa_watershed_stream(), hydroshed()

Examples

fwa_watershed_at_measure(356308001, downstream_route_measure = 10000)

Freshwater Atlas Watershed Hex

Description

Gets a 25m hexagon grid covering the fundamental watershed in which the river metre lies.

Usage

fwa_watershed_hex(
  blue_line_key,
  downstream_route_measure = 0,
  limit = 10000,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

blue_line_key

A positive whole number of the stream blue line key.

downstream_route_measure

A positive number of the river metre.

limit

A positive whole number indicating the maximum number of features to return.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Value

An sf object.

See Also

API documentation

Other functions: fwa_index_point(), fwa_locate_along(), fwa_locate_along_interval(), fwa_watershed_at_measure(), fwa_watershed_stream(), hydroshed()

Examples

## Not run: 
fwa_watershed_hex(356308001, downstream_route_measure = 10000)

## End(Not run)

Freshwater Atlas Watershed Stream

Description

Gets the upstream stream segment within the fundamental watershed.

Usage

fwa_watershed_stream(
  blue_line_key,
  downstream_route_measure = 0,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

blue_line_key

A positive whole number of the stream blue line key.

downstream_route_measure

A positive number of the river metre.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Details

This is useful for adding stream network that was not included in the watershed at measure.

Value

An sf object.

See Also

API documentation

Other functions: fwa_index_point(), fwa_locate_along(), fwa_locate_along_interval(), fwa_watershed_at_measure(), fwa_watershed_hex(), hydroshed()

Examples

fwa_watershed_stream(356308001, downstream_route_measure = 10000)

Hydroshed

Description

Gets aggregated boundary of all hydroshed polygons upstream of the provided location.

Usage

hydroshed(
  x,
  y,
  srid = 4326,
  bbox = NULL,
  properties = NULL,
  transform = NULL,
  epsg = 4326,
  nocache = getOption("fwa.nocache", FALSE)
)

Arguments

x

A number of the x coordinate.

y

A number of the y coordinate.

srid

A positive whole number of the epsg of the coordinates.

bbox

A vector of four numbers indicating bounding box to limit output features to, e.g. c(minLon, minLat, maxLon, maxLat).

properties

A vector of strings of the column names to include. If NULL (default), all columns are retained.

transform

A character vector with the name of the valid transform function followed by the parameter values (e.g. c("ST_Simplify", 100))

epsg

A positive whole number of the epsg to transform features to.

nocache

A flag specifying whether or not to cache results.

Value

An sf object.

See Also

API documentation

Other functions: fwa_index_point(), fwa_locate_along(), fwa_locate_along_interval(), fwa_watershed_at_measure(), fwa_watershed_hex(), fwa_watershed_stream()

Examples

hydroshed(x = -132.26, y = 53.36)