set_endpoint {ohsome}R Documentation

Set endpoint

Description

Modifies the endpoint of an existing ohsome_query object

Usage

set_endpoint(query, endpoint, append = FALSE, reset_format = TRUE)

set_grouping(query, grouping, ...)

Arguments

query

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

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")).

append

logical; If TRUE, the provided endpoint string is appended to the existing endpoint definition instead of replacing it. This is particularly useful if you wish to add density/ratio and/or a grouping to an existing aggregation query.

reset_format

logical; if TRUE, the format parameter of the query is updated depending on the new endpoint.

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.

...

Additional arguments passed to set_endpoint()

Details

set_endpoint() takes an ohsome_query object and modifies the ohsome API endpoint. set_grouping() takes an ohsome_query object and modifies the endpoint path for grouped aggregations.

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 Endpoints

Examples

# Query for count of elements
q <- ohsome_elements_count(
  boundary = "HD:8.5992,49.3567,8.7499,49.4371|HN:9.1638,49.113,9.2672,49.1766",
  time = "2022-01-01",
  filter = "highway=*"
)

# Modify query to aggregate length of elements instead of count
set_endpoint(q, "elements/length")

# Modify query to extract geometries instead of aggregating elements
set_endpoint(q, "elements/geometry")

# Append the endpoint path in order to group aggregation by boundary
set_endpoint(q, "groupBy/boundary", append = TRUE)

# Modify query to group aggregation by boundary
set_grouping(q, grouping = "boundary")

# Modify query to group by boundary, but keep format csv instead of geojson
set_grouping(q, grouping = "boundary", reset_format = FALSE)

# Append the endpoint path to query for element densities per boundary
set_endpoint(q, c("density", "groupBy", "boundary"), append = TRUE)

# Modify query to group aggregation by OSM element type
set_grouping(q, grouping = "type")


[Package ohsome version 0.2.2 Index]