osmdata (version 0.0.5)

osm_multipolygons: Extract all osm_multipolygons from an osmdata object

Description

id must be of an osm_point, osm_line, or osm_polygon 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

Examples

Run this code
# 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 ()
id <- rownames (dat$osm_polygons [which (dat$osm_polygons$name == "Chiswick Eyot"),])
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
# }

Run the code above in your browser using DataCamp Workspace