ropensci / rnaturalearth

An R package to hold and facilitate interaction with natural earth map data :earth_africa:
http://ropensci.github.io/rnaturalearth/
Other
214 stars 24 forks source link

Problem loading data for Czechia and Bosnia and Herzegovina #42

Closed jbracher closed 1 year ago

jbracher commented 3 years ago

I just ran into a little hiccup trying to load data for Czechia/Czech Republic:

library(rnaturalearth)
map_europe <- ne_countries(continent = "Europe")
map_europe$name[8] # this contains "Czech Rep."
# [1] "Czech Rep."
map_cz <- ne_countries(country = "Czech Rep.") # does not work
# Error in ne_countries(country = "Czech Rep.") : 
#  No such country (Czech Rep.) in the data
map_cz <- ne_countries(country = "Czechia") # does not work either
# Error in ne_countries(country = "Czechia") : 
#  No such country (Czechia) in the data

In this blog entry https://www.naturalearthdata.com/blog/miscellaneous/natural-earth-v4/ it says Czechia was now used. Maybe this switch broke something? Or am I overlooking something?

Edit: I experienced a similar problem for Bosnia and Herzegovina.

library(rnaturalearth)
map_europe <- ne_countries(continent = "Europe")
map_europe$name[5] # this contains "Bosnia and Herz."
# [1] "Bosnia and Herz."
map_bh <- ne_countries(country = "Bosnia and Herz.") # does not work
# Error in ne_countries(country = "Bosnia and Herz.") : 
#  No such country (Bosnia and Herz.) in the data

Thanks a lot for this otherwise fantastic package!

mps9506 commented 3 years ago

Just for background, the country argument searches for matches in the admin field. The following works for me:

map_europe <- ne_countries(continent = "Europe")

## search for admin names containing "Cze"
map_europe$admin[grep("Cze", map_europe$admin)]

## use the returned admin name "Czechia"
map_cz <- ne_countries(country = "Czechia")

If the above doesn't work, maybe double check the rnaturalearth and rnaturalearthdata are up to date.

For Bosnia and Herzegovina the following works for me:

map_europe$admin[grep("Bosnia", map_europe$admin)]
map_bh <- ne_countries(country = "Bosnia and Herzegovina")