ohsome_aggregate_elements {ohsome} | R Documentation |
Aggregate OSM elements
Description
Creates an ohsome_query
object for OSM element aggregation
Usage
ohsome_aggregate_elements(
boundary = NULL,
aggregation = c("count", "length", "perimeter", "area"),
return_value = c("absolute", "density", "ratio"),
grouping = NULL,
time = NULL,
...
)
ohsome_elements_count(boundary = NULL, ...)
ohsome_elements_length(boundary = NULL, ...)
ohsome_elements_perimeter(boundary = NULL, ...)
ohsome_elements_area(boundary = NULL, ...)
Arguments
boundary |
Bounding geometries specified by WGS84 coordinates in the
order
|
aggregation |
character; aggregation type:
|
return_value |
character; the value to be returned by the ohsome API:
|
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. |
time |
character; |
... |
Parameters of the request to the ohsome API endpoint. |
Details
ohsome_aggregate_elements()
creates an ohsome_query
object for
OSM element aggregation. ohsome_elements_count()
,
ohsome_elements_length()
, ohsome_elements_perimeter()
and
ohsome_elements_area()
are wrapper functions for specific aggregation
endpoints. Boundary objects are passed via set_boundary()
into
ohsome_boundary()
.
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
ohsome API Endpoints - Elements Aggregation
Examples
# Count of breweries in Franconia
ohsome_aggregate_elements(
mapview::franconia,
aggregation = "count",
filter = "craft=brewery",
time = "2022-01-01"
)
ohsome_elements_count(
mapview::franconia,
filter = "craft=brewery",
time = "2022-01-01"
)
# Monthly counts of breweries in Franconia from 2012 to 2022
ohsome_elements_count(
mapview::franconia,
filter = "craft=brewery",
time = "2012/2022/P1M"
)
# Count of breweries per district of Franconia
ohsome_elements_count(
mapview::franconia,
filter = "craft=brewery",
grouping = "boundary",
time = "2022-01-01"
)
# Number of breweries per square kilometer
ohsome_elements_count(
mapview::franconia,
filter = "craft=brewery",
return_value = "density",
time = "2022-01-01"
)
# Proportion of breweries that are microbreweries
ohsome_elements_count(
mapview::franconia,
filter = "craft=brewery",
filter2 = "craft=brewery and microbrewery=yes",
return_value = "ratio",
time = "2022-01-01"
)
# Total length of highway elements in Franconia
ohsome_elements_length(
mapview::franconia,
filter = "highway=* and geometry:line",
time = "2022-01-01"
)