osm_get_objects {osmapiR} | R Documentation |
Get OSM objects
Description
Retrieve objects by type
, id
and version
.
Usage
osm_get_objects(
osm_type,
osm_id,
version,
full_objects = FALSE,
format = c("R", "xml", "json"),
tags_in_columns = FALSE
)
Arguments
osm_type |
A vector with the type of the objects ( |
osm_id |
Object ids represented by a numeric or a character vector. |
version |
An optional vector with the version number for each object. If missing, the last version will be
retrieved. Recycled if it has different length than |
full_objects |
If |
format |
Format of the output. Can be |
tags_in_columns |
If |
Details
full_objects = TRUE
does not support specifying version
.
For ways, full_objects = TRUE
implies that it will return the way specified plus all nodes referenced by the way.
For a relation, it will return the following:
The relation itself
All nodes, ways, and relations that are members of the relation
Plus all nodes used by ways from the previous step
The same recursive logic is not applied to relations. This means: If relation r1 contains way w1 and relation r2, and w1 contains nodes n1 and n2, and r2 contains node n3, then a "full" request for r1 will give you r1, r2, w1, n1, and n2. Not n3.
Value
If format = "R"
, returns a data frame with one OSM object per row. If format = "xml"
, returns a
xml2::xml_document following the
OSM_XML format. If format = "json"
,
returns a list with a json structure following the OSM_JSON format.
Objects are sorted in the same order than osm_id
except for full_objects = TRUE
, where the nodes comes first,
then ways, and relations at the end as specified by
OSM_XML format.
Note
For downloading data for purposes other than editing or exploring the history of the objects, perhaps is better to
use the Overpass API. A similar function to download OSM objects by type
and id
using Overpass, is implemented in
the osmdata function opq_osm_id()
.
See Also
Other get OSM objects' functions:
osm_bbox_objects()
,
osm_history_object()
,
osm_relations_object()
,
osm_ways_node()
,
osmapi_objects()
Examples
## Not run:
obj <- osm_get_objects(
osm_type = c("node", "way", "way", "relation", "relation", "node"),
osm_id = c("35308286", "13073736", "235744929", "40581", "341530", "1935675367"),
version = c(1, 3, 2, 5, 7, 1)
)
obj
## End(Not run)