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 ("node", "way" or "relation"). Recycled if it has a different length than osm_id.

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 osm_id.

full_objects

If TRUE, retrieves all other objects referenced by ways or relations. Not compatible with version.

format

Format of the output. Can be "R" (default), "xml", or "json".

tags_in_columns

If FALSE (default), the tags of the objects are saved in a single list column ⁠tags``` containing a ⁠data.frame⁠for each OSM object with the keys and values. If⁠TRUE⁠, add a column for each key. Ignored if ⁠format != "R"'.

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:

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)

[Package osmapiR version 0.1.0 Index]