Learn R Programming

osmplotr (version 0.2.0)

extract_osm_objects: extract_osm_objects

Description

Downloads OSM XML objects and extracts 'sp' polygons or lines. Requires conversion to osmar object which can be quite slow, as can final conversion to sp object for large numbers of objects

Usage

extract_osm_objects(key, value, extra_pairs, bbox, verbose = FALSE)

Arguments

key
OSM key to search for. Useful keys include 'building', 'waterway', 'natural', 'grass', 'park', 'amenity', 'shop', 'boundary', and 'highway'. Others will be passed directly to the overpass API and may not necessarily return results.
value
OSM value to match to key. If NULL, all keys will be returned. Negation is specified by '!value'.
extra_pairs
A list of additional key-value pairs to be passed to the overpass API.
bbox
the bounding box within which all key-value objects should be downloaded. A 2-by-2 matrix of 4 elements with columns of min and max values, and rows of x and y values.
verbose
If TRUE, provides notification of progress

Value

  • A data frame of sp objects

See Also

add_osm_objects.

Examples

Run this code
bbox <- get_bbox (c(-0.13,51.50,-0.11,51.52))
dat_B <- extract_osm_objects (key='building', bbox=bbox)
dat_H <- extract_osm_objects (key='highway', bbox=bbox)
dat_BR <- extract_osm_objects (key='building', value='residential', bbox=bbox)
dat_HP <- extract_osm_objects (key='highway', value='primary', bbox=bbox)
dat_HNP <- extract_osm_objects (key='highway', value='!primary', bbox=bbox)
extra_pairs <- c ('name', 'Royal.Festival.Hall')
dat <- extract_osm_objects (key='building', extra_pairs=extra_pairs, bbox=bbox)

Run the code above in your browser using DataLab