Remove names from osmdata
geometry objects, for cases in which these cause
issues, particularly with plotting, such as
https://github.com/rstudio/leaflet/issues/631, or
https://github.com/r-spatial/sf/issues/1177. Note that removing these
names also removes any ability to inter-relate the different components of an
osmdata
object, so use of this function is only recommended to resolve
issues such as those linked to above.
See also
Other transform:
osm_elevation()
,
osm_poly2line()
,
trim_osmdata()
,
unique_osmdata()
Examples
# Bounding box of "hampi india":
bb <- c (76.4410201, 15.3158, 76.4810201, 15.3558)
query <- opq (bb)
query <- add_osm_feature (query, key = "historic", value = "ruins")
# Equivalent to:
if (FALSE) { # \dontrun{
query <- opq ("hampi india") |>
add_osm_feature (key = "historic", value = "ruins")
} # }
# Then extract data from 'Overpass' API
if (FALSE) { # \dontrun{
hampi_sf <- osmdata_sf ()
} # }
# Remove rownames from all geometry metrices:
if (FALSE) { # \dontrun{
hampi_clean <- unname_osmdata_sf (hampi_sf)
# All coordinate matrices include rownames with OSM ID values:
head (as.matrix (hampi_sf$osm_lines$geometry [[1]]))
# But 'unname_osmdata_sf' removes both row and column names:
head (as.matrix (hampi_clean$osm_lines$geometry [[1]]))
} # }