A first go at creating an atlas of admin boundaries for all African countries using GADM data (probably most easily accessible admin boundary data but not most up-to-date).

#initial creation of this file
#usethis::use_vignette("afriadmin-atlas")

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(afriadmin)
#data("afcountries")

#TEST to avoid error in gzfile readRDS I'm getting
#afcountries <- afcountrynames(nameoriso3c = 'both', filtercountries='gadm2')

#Somalia SOM seems to have level2 but not level 0 or 1
#leave it out for now
afcountries <- afcountries[(!afcountries$iso3c %in% c('SOM')),]

#I could add other countries in grey to give context

#even hires naturalearth still shows reasaonable differences from gadm
#sf_ne_africa <- rnaturalearth::ne_countries(scale = 'large', type = "countries", continent = 'africa', returnclass='sf')

#an all africa adm0 object from gadm saved to the package (will need to ask permission)
#data(sf_af_gadm0) 

for(countrynum in 1:nrow(afcountries))
{

  name <- afcountries$name[countrynum]
  iso3c <- afcountries$iso3c[countrynum]
  maxlevel <- maxadmin(iso3c, datasource='gadm')

  #cat(name," ",iso3c," levels=",maxlevel,"\n")

  afplotadmin(country=name, datasource='gadm')

}


afrimapr/afriadmin documentation built on Dec. 15, 2021, 2:35 p.m.