set_boundary {ohsome}R Documentation

Set boundary

Description

Set or modify the spatial filter of an existing ohsome_query object

Usage

set_boundary(query, boundary = NULL, ...)

Arguments

query

An ohsome_query object constructed with ohsome_query() or any of its wrapper functions

boundary

Bounding geometries specified by WGS84 coordinates in the order ⁠lon,lat⁠. The geometries of sf are transformed to WGS84 if the CRS of the object is known. The following classes are supported:

  • sf with (MULTI)POLYGON geometries

  • sfc with (MULTI)POLYGON geometries

  • sfg with (MULTI)POLYGON geometries and WGS 84 coordinates

  • bbox created with sf::st_bbox() or tmaptools::bb()

  • matrix created with sp::bbox() or osmdata::getbb()

  • character providing textual definitions of bounding polygons, boxes or circles as allowed by the ohsome API (see ohsome API - Boundaries ):

    • bboxes: WGS84 coordinates in the following format: "id1:lon1,lat1,lon2,lat2|id2:lon1,lat1,lon2,lat2|..." OR "lon1,lat1,lon2,lat2|lon1,lat1,lon2,lat2|..."

    • bcircles: WGS84 coordinates + radius in meter in the following format: "id1:lon,lat,r|id2:lon,lat,r|..." OR "lon,lat,r|lon,lat,r|..."

    • bpolys: WGS84 coordinates given as a list of coordinate pairs (as for bboxes) or GeoJSON FeatureCollection. The first point has to be the same as the last point and MultiPolygons are only supported in GeoJSON.

  • list of bbox, matrix or character. Bounding geometry types of all list elements must be the same. Does not work with GeoJSON FeatureCollections.

...

Additional arguments other than digits are ignored.

Details

set_boundary() adds a spatial filter to an ohsome_query object or replaces an existing one. The spatial filter of a query to the ohsome API can be defined as one or more polygons, bounding boxes or bounding circles.

Value

An ohsome_query object. The object can be sent to the ohsome API with ohsome_post(). It consists of the following elements:

See Also

ohsome API documentation

Examples

# Query without boundary definition
q <- ohsome_query(
    "elements/count/groupBy/boundary", 
    filter = "building=*",
    time = "2022-01-01"
)

# Use franconia from the mapview package as bounding polygons

set_boundary(q, mapview::franconia, digits = 4)


# Use the bounding box of franconia

set_boundary(q, sf::st_bbox(mapview::franconia))


## Not run: 
# Get bounding box of the city of Kigali from OSM
set_boundary(q, osmdata::getbb("Kigali"))

## End(Not run)

# Definition of two named bounding circles
set_boundary(q, c("Circle 1:8.6528,49.3683,1000", "Circle 2:8.7294,49.4376,1000"))


[Package ohsome version 0.2.2 Index]