Skip to contents

Reduce the components of an osmdata object in 'sf' or 'sp' form (that is, obtained from osmdata_sf or osmdata_sp) to only unique items of each type. That is, reduce $osm_points to only those points not present in other objects (lines, polygons, etc.); reduce $osm_lines to only those lines not present in multiline objects; and reduce $osm_polygons to only those polygons not present in multipolygon objects. This renders an osmdata object more directly compatible with typical output of sf.

Usage

unique_osmdata(dat)

Arguments

dat

An osmdata object

Value

Equivalent object reduced to only unique objects of each type

See also

Examples

# Bounding box of "Colchester UK":
bb <- c (0.6993788, 51.7657055, 1.026803, 51.977153)
query <- opq (bb)
query <- add_osm_feature (query, key = "highway")
# Equivalent to:
if (FALSE) { # \dontrun{
query <- opq ("colchester uk") |>
    add_osm_feature (key = "highway")
} # }
# Then extract data from 'Overpass' API
if (FALSE) { # \dontrun{
dat <- osmdata_sf (query)
dat
} # }
# Then reduce to unique items of each type only:
if (FALSE) { # \dontrun{
dat <- unique_osmdata (dat)
dat
} # }
# And objects of each type (points, line, polygons, and so on) now have
# fewer members.