osm_bbox_objects {osmapiR} | R Documentation |
Retrieve map data by bounding box
Description
The following command returns:
All nodes that are inside a given bounding box and any relations that reference them.
All ways that reference at least one node that is inside a given bounding box, any relations that reference them [the ways], and any nodes outside the bounding box that the ways may reference.
All relations that reference one of the nodes, ways or relations included due to the above rules. (Does ”'not”' apply recursively, see explanation below.)
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 ( |
format |
Format of the output. Can be |
tags_in_columns |
If |
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:
There is a relation named "England" that references every node in England.
The nodes, ways, and relations are retrieved for a bounding box that covers a small portion of England. While the result would include the nodes, ways, and relations as specified by the rules for the command, including the "England" relation, it would (fortuitously) not include every node and way in England. If desired, the nodes and ways referenced by the "England" relation could be retrieved by their respective IDs.
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