Compare HDX live admin boundaries (available for c 32 african countries) with GADM. Where the boundaries are consistent between the two sources they appear dark red, where they diverge they are lighter red or blue.

#initial creation of this file
#usethis::use_vignette("gadm-hdx-compare")

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(afriadmin)
  path <- system.file(package="afriadmin",paste0("external/hdxlive/"))

  #vector of iso3c codes with hdx live boundaries given by the folder list
  v_iso3c <- list.files(path)

  #TODO check the levels available for each country
  #path <- system.file(package="afriadmin",paste0("external/hdxlive/",iso3clow,"/",level))

#data("afcountries")

#Somalia SOM seems to have level2 but not level 0 or 1 in gadm
#COM comoros only has level 1 for gadm
#miss out these for now
v_iso3c <- v_iso3c[ -which(v_iso3c%in% c("COM","SOM"))]


for(countrynum in 1:length(v_iso3c))
{
  iso3c <- v_iso3c[countrynum]  
  name <- iso2country(iso3c)

  #gadm max level
  maxlevel <- maxadmin(iso3c, datasource='gadm')

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

  for(level in 1:maxlevel) 
  {
    hdxlive(country=name, level=level, plot='compare_sf') 
    # would be good to get mapview plots in a html doc, but the below didn't seem to work
    #hdxlive(country=name, level=level, plot='compare_mapview') 
  }

}


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