ropensci / rnaturalearth

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

France is missing #30

Closed matteodefelice closed 1 year ago

matteodefelice commented 4 years ago

This happens both with the CRAN and the devtools versions of this package.

eu_sf <- ne_countries(scale = 50, returnclass = 'sf')
eu_sf %>% dplyr::filter(iso_a2 == 'FR') %>% nrow()
[1] 0

Is the same with iso_a3 or other fields. France is missing. It is instead present when the scale is 110.

mps9506 commented 4 years ago

I was wondering if this is still an issue? It is working for me.

 eu_sf <- ne_countries(scale = 50, returnclass = 'sf')
 eu_sf %>% 
   dplyr::filter(iso_a2 == 'FR') %>% 
   nrow()
[1] 1
matteodefelice commented 4 years ago

It's still an issue, both , bdownloading rnaturalearth from CRAN or from the github repository.

mps9506 commented 4 years ago

Can you provide your sessionInfo()?

Also what does the non-filtered eu_sf return?

matteodefelice commented 4 years ago

eu_sf is this (showing only the first lines of output)

> head(eu_sf)
Simple feature collection with 6 features and 94 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: -73.36621 ymin: -22.40205 xmax: 109.4449 ymax: 41.9062
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
       featurecla scalerank labelrank sovereignt sov_a3 adm0_dif level
0 Admin-0 country         1         3   Zimbabwe    ZWE        0     2
1 Admin-0 country         1         3     Zambia    ZMB        0     2
2 Admin-0 country         1         3      Yemen    YEM        0     2
3 Admin-0 country         3         2    Vietnam    VNM        0     2
4 Admin-0 country         5         3  Venezuela    VEN        0     2
5 Admin-0 country         6         6    Vatican    VAT        0     2

This is my sessionInfo:

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rnaturalearth_0.2.0 sf_0.8-1           

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4              rstudioapi_0.11        
 [3] magrittr_1.5            units_0.6-6            
 [5] tidyselect_1.0.0        lattice_0.20-40        
 [7] R6_2.4.1                rlang_0.4.5            
 [9] rnaturalearthdata_0.2.0 httr_1.4.1             
[11] dplyr_0.8.5             tools_3.6.3            
[13] grid_3.6.3              packrat_0.5.0          
[15] KernSmooth_2.23-16      e1071_1.7-3            
[17] DBI_1.1.0               rgeos_0.5-2            
[19] class_7.3-16            assertthat_0.2.1       
[21] tibble_2.1.3            crayon_1.3.4           
[23] purrr_0.3.3             glue_1.3.2             
[25] sp_1.4-1                compiler_3.6.3         
[27] pillar_1.4.3            classInt_0.4-2         
[29] jsonlite_1.6.1          pkgconfig_2.0.3   
mps9506 commented 4 years ago

For some reason I end up with a different simple feature. The order and number of variables that my eu_sf ends up different. It might be worth trying to update the rnaturalearthdata package. I don't know if that will fix it though.

So I used the ne_download function and ended up with (I think) the same data you have (note that the variable names are capitalized here):

eu_sf <- ne_download(scale = 50, type = "admin_0_countries", returnclass = "sf") 

eu_sf %>%
  dplyr::filter(ISO_A2 == 'FR') %>% 
  nrow()

However, when I explored the eu_sf object more, there is a row for France, but the ISO_A2 field is NA. So the following seems to work:

eu_sf %>%
  dplyr::filter(FIPS_10_ == 'FR') %>% 
  nrow()

[1] 1

Would be good to troubleshoot how we ended up with different simple features using ne_countries().

matteodefelice commented 4 years ago

Thanks, using fips_10 works but of course is not the same, I want to use ISO codes. It is curious that ne_download and ne_countries return different things.

mps9506 commented 4 years ago

Understandable. I dug around some more. It looks like the missing ISO codes are a tracked issue over in the Natural Earth repo: https://github.com/nvkelso/natural-earth-vector/issues/284#issue-425441544

PMassicotte commented 1 year ago

Seems to be working properly in the current version of the package. Please feel free to reopen if you still experience issues.

nbreznau commented 4 months ago

I am using the most recent rnaturalearth package and France and Norway are still missing from the variable 'iso_a3'. However, they are present in 'iso_a3_eh'. So for example, you could replace missing values with those to get the full map.

wi_map <- ne_countries(returnclass = "sf") %>% # generate wi_map object

  mutate(id = iso_a3,
         id = ifelse(id == "-99", iso_a3_eh, id)) %>% # replace missing codes for FRA and NOR

  select(id, geometry)
PMassicotte commented 4 months ago

we are only providing the data offered by naturalearth. You should contact them if you find errors.