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 |
endpoint |
The path to the
ohsome API endpoint.
Either a single string (e.g. |
append |
logical; If |
reset_format |
logical; if |
grouping |
character; group type(s) for grouped aggregations (only available for queries to aggregation endpoints). The following group types are available:
Not all of these group types are accepted by all of the aggregation endpoints. Check Grouping for available group types. |
... |
Additional arguments passed to |
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:
-
url
: The URL of the endpoint. -
encode
: The way the information is encoded and then posted to the ohsome API. Set as"form"
. -
body
: The parameters of the query such asformat
,filter
orbpolys
.
See Also
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")