# 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")
Run the code above in your browser using DataLab