Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

osm_multipolygons

Extract all osm_multipolygons from an osmdata object


Description

id must be of an osm_points, osm_lines, or osm_polygons object. osm_multipolygons returns any multipolygon object(s) which contain the object specified by id.

Usage

osm_multipolygons(dat, id)

Arguments

dat

An object of class osmdata

id

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

Value

An sf Simple Features Collection of multipolygons

See Also

Examples

## Not run: 
# find all multipolygons which contain the single polygon called
# "Chiswick Eyot" (which is an island).
dat <- opq ("London UK") %>%
    add_osm_feature (key = "name", value = "Thames", exact = FALSE) %>%
    osmdata_sf ()
index <- which (dat$osm_multipolygons$name == "Chiswick Eyot")
id <- rownames (dat$osm_polygons [id, ])
osm_multipolygons (dat, id)
# That multipolygon is the Thames itself, but note that
nrow (dat$osm_multipolygons) # = 14 multipolygon objects
nrow (osm_multipolygons (dat, id)) # = 1 - the main Thames multipolygon

## End(Not run)

osmdata

Import 'OpenStreetMap' Data as Simple Features or Spatial Objects

v0.1.10
GPL-3
Authors
Mark Padgham [aut, cre], Bob Rudis [aut], Robin Lovelace [aut], Maëlle Salmon [aut], Andrew Smith [ctb], James Smith [ctb], Andrea Gilardi [ctb], Enrico Spinielli [ctb], Anthony North [ctb], Martin Machyna [ctb], Marcin Kalicinski [ctb, cph] (Author of included RapidXML code)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.