Learn R Programming

osmdata (version 0.3.0)

osm_polygons: Extract all osm_polygons from an osmdata_sf object

Description

If id is of a point object, osm_polygons will return all polygons containing that point. If id is of a line or polygon object, osm_polygons will return all polygons which intersect the given line or polygon.

Usage

osm_polygons(dat, id)

Value

An sf Simple Features Collection of polygons

Arguments

dat

An object of class osmdata_sf

id

OSM identification of one or more objects for which polygons are to be extracted

See Also

Other search: osm_lines(), osm_multilines(), osm_multipolygons(), osm_points()

Examples

Run this code
# Extract polygons which intersect Conway Street in London
if (FALSE) {
dat <- opq ("Marylebone London") |>
    add_osm_feature (key = "highway") |>
    osmdata_sf ()
conway <- which (dat$osm_lines$name == "Conway Street")
id <- rownames (dat$osm_lines [conway, ])
osm_polygons (dat, id)
}

Run the code above in your browser using DataLab