rOpenGov / giscoR

Download geospatial data from GISCO API - Eurostat
https://ropengov.github.io/giscoR/
GNU General Public License v3.0
73 stars 1 forks source link

Cyprus is missing from the region Europe #18

Closed lodderig closed 3 years ago

lodderig commented 3 years ago

Hi,

Great package. Small note that I observed that Cyprus is missing when you use gisco_get_countries with the option Region="Europe".

dieghernan commented 3 years ago

Hi,

I have to say that I though a lot about this particular case when developing the package. The source for region (and the whole giscoR::gisco_countrycode table, that is the underlying data) is the package countrycode by @vincentarelbundock.

Specifically, the region is assessed against un.region.name:

https://github.com/dieghernan/giscoR/blob/d7a7c822c129ee7b5162343d1df64de7693143e0/R/gisco_get.R#L299-L303

So the package uses UN Region coding system. On the UN methodology (https://unstats.un.org/unsd/methodology/m49/) Cyprus is classified under Asia > Western Asia

Captura

Hope this clarifies the point.

dieghernan commented 3 years ago

I included this as a note on the manual of the package, as you can check:

region Optional. A character vector of UN M49 region codes. Possible values are "Africa", "Americas", "Asia", "Europe", "Oceania".

vincentarelbundock commented 3 years ago

Thanks for the ping @dieghernan .

We try to make as few editorial decisions as absolutely necessary in countrycode. I consider to be errors codes that are included in countrycode but that do not match an official code list from the documented source.

If you find an error in one of the codes, please file an issue on Github and we will be more than happy to take a look.

vincentarelbundock commented 3 years ago

FYI, all the original data we scraped to create our table can be found here: https://github.com/vincentarelbundock/countrycode/tree/main/dictionary

dieghernan commented 3 years ago

Still the regional classification of Cyprus seems to be a bit controversial. I know it is not the best source, but as per Wikipedia:

https://en.wikipedia.org/wiki/Cyprus#Geography

...Sources alternatively place Cyprus in Europe,[138][139][140] or Western Asia and the Middle East.[141][142]

vincentarelbundock commented 3 years ago

Oh for sure! I'd just prefer that the United Nations deal with the controversy rather than me ;)

lodderig commented 3 years ago

I included this as a note on the manual of the package, as you can check:

region Optional. A character vector of UN M49 region codes. Possible values are "Africa", "Americas", "Asia", "Europe", "Oceania".

Thanks for the clarification. Given that GISCO is a service from the European Union, using the UN classification is slightly counterintuitive, as one might select not the data one expects. Maybe it is helpful to mention that Cyprus is not part of Europe in the Region parameter and that for the EU countries it is recommended to use the Country parameter and not the Region.

dieghernan commented 3 years ago

Following your comments, I have added a new valid value for gisco_get_countries(region). Now you can also use "EU" as region to get the 27 current members (post-Brexit).

You can also combine it (region = c("Europe", "EU")) to get both the UN region and the EU members.

Documentation was updated and Cyprus case is specifically mentioned: https://dieghernan.github.io/giscoR/reference/gisco_get.html#details

By last, you can also use gisco_get_nuts(nuts_level = 0) to get all the country-level polygons of the countries included in the NUTS scheme, that includes also non EU countries (as Finland, Norway, Iceland, Turkey, etc.). See https://ec.europa.eu/eurostat/web/nuts/national-structures#Abbreviations

library(giscoR)
sort(gisco_get_countries(region = c("Europe","EU"))$NAME_ENGL)
#>  [1] "Albania"                "Andorra"                "Austria"               
#>  [4] "Belarus"                "Belgium"                "Bosnia and Herzegovina"
#>  [7] "Bulgaria"               "Croatia"                "Cyprus"                
#> [10] "Czechia"                "Denmark"                "Estonia"               
#> [13] "Faroes"                 "Finland"                "France"                
#> [16] "Germany"                "Gibraltar"              "Greece"                
#> [19] "Guernsey"               "Hungary"                "Iceland"               
#> [22] "Ireland"                "Isle of Man"            "Italy"                 
#> [25] "Jersey"                 "Latvia"                 "Liechtenstein"         
#> [28] "Lithuania"              "Luxembourg"             "Malta"                 
#> [31] "Moldova"                "Monaco"                 "Montenegro"            
#> [34] "Netherlands"            "North Macedonia"        "Norway"                
#> [37] "Poland"                 "Portugal"               "Romania"               
#> [40] "Russian Federation"     "San Marino"             "Serbia"                
#> [43] "Slovakia"               "Slovenia"               "Spain"                 
#> [46] "Svalbard and Jan Mayen" "Sweden"                 "Switzerland"           
#> [49] "Ukraine"                "United Kingdom"         "Vatican City"

sort(gisco_get_nuts(nuts_level = 0)$NAME_LATN)
#>  [1] "BELGIQUE-BELGIË "                   "BULGARIA"                          
#>  [3] "CESKÁ REPUBLIKA"                    "CRNA GORA"                         
#>  [5] "DANMARK"                            "DEUTSCHLAND"                       
#>  [7] "EESTI"                              "ELLADA"                            
#>  [9] "ESPAÑA "                            "FRANCE"                            
#> [11] "HRVATSKA"                           "IRELAND"                           
#> [13] "ÍSLAND"                             "ITALIA"                            
#> [15] "KYPROS"                             "LATVIJA"                           
#> [17] "LIECHTENSTEIN"                      "LIETUVA"                           
#> [19] "LUXEMBOURG"                         "MAGYARORSZÁG"                      
#> [21] "MALTA"                              "NEDERLAND"                         
#> [23] "NORGE"                              "North Macedonia"                   
#> [25] "ÖSTERREICH"                         "POLSKA"                            
#> [27] "PORTUGAL"                           "REPUBLIKA SRBIJA /<U+0420><U+0415><U+041F><U+0423><U+0411><U+041B><U+0418><U+041A><U+0410> <U+0421><U+0420><U+0411><U+0418><U+0408><U+0410>"
#> [29] "ROMÂNIA"                            "SCHWEIZ/SUISSE/SVIZZERA"           
#> [31] "SHQIPËRIA"                          "SLOVENIJA"                         
#> [33] "SLOVENSKO"                          "SUOMI / FINLAND"                   
#> [35] "SVERIGE"                            "TÜRKIYE"                           
#> [37] "UNITED KINGDOM"

Created on 2021-02-11 by the reprex package (v1.0.0)

lodderig commented 3 years ago

Thanks a lot, works like a charm.