ropensci / osmdata

R package for downloading OpenStreetMap data
https://docs.ropensci.org/osmdata
317 stars 45 forks source link

[BUG] Fix duplicate column names #348

Closed mpadge closed 2 months ago

mpadge commented 2 months ago

For https://github.com/r-spatial/mapview/issues/492, with reprex from there thanks to @tim-salabim

library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(mapview)

# Example Polygons
# OSM public data buildings marburg
# load OSM data for the Marburg region

buildings <- osmdata::opq(bbox = "marburg de") %>%
  osmdata::add_osm_feature(key = "building") %>%
  osmdata::osmdata_sf()

buildings <- buildings$osm_polygons

anyDuplicated(tolower(names(buildings)))
#> [1] 113

names(buildings)[113]
#> [1] "fixme"

grep("fixme", tolower(names(buildings)))
#> [1]   3 113

names(buildings)[c(3, 113)]
#> [1] "FIXME" "fixme"

names(buildings)[113] = "fixme2"

@edzer Yep, I'll fix that over here. Thanks for heads-up :+1:

mpadge commented 2 months ago
library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
packageVersion ("osmdata")
#> [1] '0.2.5.23'
buildings <- osmdata::opq(bbox = "marburg de") %>%
  osmdata::add_osm_feature(key = "building") %>%
  osmdata::osmdata_sf()

buildings <- buildings$osm_polygons
any(duplicated(tolower(names(buildings))))
#> [1] FALSE

Created on 2024-09-25 with reprex v2.1.1