0

I am having troubles with the German Umlaute (ä, ü, ö) and other signs when using osmdata in R.

I can successfully get the data via query (notice the Ü in the bounding box in the first line, it is working fine):

#install.packages("osmdata")
#library(osmdata)

bw <- osmdata::getbb("Baden-Württemberg") %>% 
  osmdata::opq(timeout = 25*100) %>%
  osmdata::add_osm_feature(
    key = "admin_level", 
    value = "4"
  ) %>%
  osmdata::osmdata_sf()

Having a look at the data, one can see that the umlaute aren't displayed correctly.

View(bw$osm_multipolygons)

Consequently, searching by "name" doesn't work anymore:

dplyr::filter(bw$osm_multipolygons, name == "Tirol")
dplyr::filter(bw$osm_multipolygons, name == "Baden-Württemberg")

Tirol is working (no umlaut), Baden-Württemberg (with the ü) isn't.

I'm running R on a German Windows 10, R is running in English.

Best regards

Maël
  • 45,206
  • 3
  • 29
  • 67
BanffBoss122
  • 149
  • 9
  • Here is one group that had a similar issue: https://stackoverflow.com/questions/61490124/how-to-keep-umlaut-in-r if you read their comments, suggestions (there is a link to follow at the very bottom too), you may hopefully find a solution to your problem. All the best. – Andy Feb 21 '22 at 09:18
  • What do you mean with "aren't displayed correctly"? If I run your code and do ``bw$osm_multipolygons %>% as_tibble() %>% filter(name == "Baden-Württemberg")`` I get one row containing the polygon of BW. This can simply be plotted using e.g. ggplot via ``geom_sf()`` – mgrund Feb 21 '22 at 15:14
  • I do not the same result. I get a "Simple feature collection with 0 features and 194 fields". The Ü isn't displayed correctly when I use View(), I get weird looking symbols: Baden-Württemberg – BanffBoss122 Feb 22 '22 at 16:36

1 Answers1

0

The current working solution for me is described here:

Importing Open Street Map data gives wrong encoding

It is really annoying because a) I am using a function which I don't understand b) it seems to work for other people (@mrgrund)

on the other side, it seems I am not the only person with the problem.

Best regards

BanffBoss122
  • 149
  • 9