rOpenGov / giscoR

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

States/provinces for other countries #49

Closed elijahrona closed 1 year ago

elijahrona commented 1 year ago

First of all, thank you so much for the package.

If I want to create a map of Nigeria, I only see the map (as in the outline) without the states nor state borders.

Imagining I want to compare the states of Nigeria, is it possible with your package?

Thank you.

dieghernan commented 1 year ago

Hi @elijahrona

Although giscoR provides country-level data for all the countries in the world, the sub-national data is only available for European countries (and more specifically countries members/candidates of the European Union). On this, remember that giscoR uses the data available on GISCO (the the Geographic Information System of the European Commission).

If you need to get sub-national shapefiles I recommend you the following data souces:

The good news is that there are a bunch of R packages that allows you to query these databases straight on your session:

Specifically, if you want political boundaries of any African country, It is worth also to check the package afriadmin (GitHub), by the afrimapr project. This package uses either geoboundaries or GADM via the option datasource.

Finally, I also recommend the package countrycodes (CRAN) to easily convert between names and country codes. This is useful since some packages would request the country names while others requires the ISO3 code.

Find here a reproducible example showing how to download geographic data for Nigeria with each of the suggested packages:

# For plotting
library(ggplot2)

# On CRAN ----
# install.packages("geodata")

library(geodata)
#> Loading required package: terra
#> terra 1.6.47
nig_geodata <- geodata::gadm("Nigeria",
  level = 1,
  path = tempdir()
) |>
  sf::st_as_sf() # Provided in SpatVector (terra) format, convert it to sf

ggplot(nig_geodata) +
  geom_sf() +
  labs(
    title = "Nigeria, Level 1",
    subtitle = "package geodata (CRAN)"
  )


# On GitHub ----

# remotes::install_github("IamKDO/GADMTools")
library(GADMTools)

# Note the $sf at the end
nig_gadmtools <- gadm_sf_loadCountries("NGA", level = 1)$sf

ggplot(nig_gadmtools) +
  geom_sf() +
  labs(
    title = "Nigeria, Level 1",
    subtitle = "package GADMTools (GitHub)"
  )
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()


# remotes::install_github("wmgeolab/rgeoboundaries")

library(rgeoboundaries)

ggplot(nig_geobondaries) +
  geom_sf() +
  labs(
    title = "Nigeria, Level 1",
    subtitle = "package rgeoboundaries (GitHub)"
  )


# Specific for Africa
# remotes::install_github("afrimapr/afriadmin")
library(afriadmin)
nig_afriadmin <- afriadmin("nigeria", level = 1, plot = FALSE)

ggplot(nig_afriadmin) +
  geom_sf() +
  labs(
    title = "Nigeria, Level 1",
    subtitle = "package afriadmin (GitHub)"
  )

Created on 2023-01-09 with reprex v2.0.2

elijahrona commented 1 year ago

OMG thanks a lot for your help.

I will try them then. I really appreciate you.

dieghernan commented 1 year ago

Check also this app to compare both geoboundaries and GADM data sources on a interactive map (kudos to @andysouth)!

https://andysouth.shinyapps.io/afriadmin-compare/

elijahrona commented 1 year ago

Check also this app to compare both geoboundaries and GADM data sources on a interactive map (kudos to @andysouth)!

https://andysouth.shinyapps.io/afriadmin-compare/

Thanks a lot. I am currently practicing.20230109_111118.jpg