ropensci / osmdata

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

[BUG] `osmdata_*` functions return features with changed tag names for tags with non-valid names #301

Closed jmaspons closed 1 year ago

jmaspons commented 1 year ago

As per make.names, valid syntactic names only include letters, numbers and the dot or underline characters and starts with a letter. For exemple, many keys in OSM contain also : which get transformed to ., then name:ca becomes name.ca

Non-valid names are not a big problem in R. Columns can be accessed anyway by df$`key:xx` or df[, "key:xx"]. Name changes can be aboided with data.frame(..., check.names=FALSE). I will try to make a PR if you agree with the behavior change.

mpadge commented 1 year ago

Yes indeed! I had this in mind recently. I was working directly from a local .pbf, converting filtered bits to .osm, and then reading with osmdata_xml. That yielded data.frames with intact : in names, but i ran into issues combining with other data generated in other ways which had converted : -> .. I wrote a hacky work-around, but a proper solution would be better. And by "proper" i mean here ensuring that all OSM keys with : are ultimately retained and not converted to .. That'd be really cool, thanks!