ohsome_query {ohsome}R Documentation

Create an ohsome_query object

Description

Creates an ohsome_query object specifying the ohsome API endpoint and the request parameters.

Usage

ohsome_query(endpoint, boundary = NULL, grouping = NULL, ..., validate = FALSE)

Arguments

endpoint

The path to the ohsome API endpoint. Either a single string (e.g. "elements/count") or a vector of character in the right order (e.g. c("elements", "count")).

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.

grouping

character; group type(s) for grouped aggregations (only available for queries to aggregation endpoints). The following group types are available:

  • "boundary" groups the result by the given boundaries that are defined through any of the boundary query parameters.

  • "key" groups the result by the given keys that are defined through the groupByKeys query parameter.

  • "tag" groups the result by the given tags that are defined through the groupByKey and groupByValues query parameters.

  • "type" groups the result by OSM element type.

  • c("boundary", "tag") groups the result by the given boundaries and tags.

Not all of these group types are accepted by all of the aggregation endpoints. Check Grouping for available group types.

...

Parameters of the request to the ohsome API endpoint.

validate

logical; if TRUE, issues warning for invalid endpoint or invalid/missing query parameters.

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

# Extract building geometries with manually set bboxes parameter
ohsome_query(
    "elements/geometry", 
    bboxes = "8.6,49.36,8.75,49.44", 
    time = "2022-01-01",
    filter = "building=*"
)

# Extract building geometries using a boundary object:
ohsome_query(
    "elements/geometry", 
    boundary = "8.6,49.36,8.75,49.44", 
    time = "2022-01-01",
    filter = "building=*"
)


[Package ohsome version 0.2.2 Index]