osm_bbox_objects {osmapiR}R Documentation

Retrieve map data by bounding box

Description

The following command returns:

Usage

osm_bbox_objects(bbox, format = c("R", "xml", "json"), tags_in_columns = FALSE)

Arguments

bbox

Coordinates for the area to retrieve the map data from (⁠left,bottom,right,top⁠).

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

Note that, while this command returns those relations that reference the aforementioned nodes and ways, the reverse is not true: it does not (necessarily) return all of the nodes and ways that are referenced by these relations. This prevents unreasonably-large result sets. For example, imagine the case where:

Also note that ways which intersect the bounding box but have no nodes within the bounding box will not be returned.

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.

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 using Overpass, is implemented in the osmdata function opq().

See Also

Other get OSM objects' functions: osm_get_objects(), osm_history_object(), osm_relations_object(), osm_ways_node(), osmapi_objects()

Examples

map_data <- osm_bbox_objects(bbox = c(1.8366775, 41.8336843, 1.8379971, 41.8344537))
## bbox as a character value also works (bbox = "1.8366775,41.8336843,1.8379971,41.8344537").
map_data

[Package osmapiR version 0.1.0 Index]