extract_osm_objects: extract_osm_objects

extract_osm_objectsR Documentation

extract_osm_objects

Description

Downloads OSM XML objects and converts to sp objects (SpatialPointsDataFrame, SpatialLinesDataFrame, or SpatialPolygonsDataFrame).

Usage

extract_osm_objects(
  bbox,
  key = NULL,
  value,
  extra_pairs,
  return_type,
  sf = TRUE,
  geom_only = FALSE,
  quiet = FALSE
)

Arguments

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.

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.

return_type

If specified, force return of spatial (point, line, polygon, multiline, multipolygon) objects. return_type = 'line' will, for example, always return a SpatialLinesDataFrame. If not specified, defaults to 'sensible' values (for example, lines for highways, points for trees, polygons for buildings).

sf

If TRUE, return Simple Features (sf) objects; otherwise Spatial (sp) objects.

geom_only

If TRUE, return only those OSM data describing the geometric object; otherwise return all data describing each object.

quiet

If FALSE, provides notification of progress.

Value

Either a SpatialPointsDataFrame, SpatialLinesDataFrame, or SpatialPolygonsDataFrame.

See Also

add_osm_objects.

Other data-extraction: connect_highways(), get_bbox()

Examples

## Not run: 
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
)

## End(Not run)

mpadge/osmplotr documentation built on Oct. 28, 2024, 11:45 a.m.