## function to get the boundaries of countries from different sources in a standardized way
readCountries <- function(countries="DIVA GIS", cache=T) {
if (countries=="DIVA GIS"){
if (file.exists(paste0(geodata$config$mainfolder, "cache/DIVA_GIS_boundaries.rda")) & cache==T) {
load(paste0(geodata$config$mainfolder, "cache/DIVA_GIS_boundaries.rda"))
} else {
boundaries <- rgdal::readOGR(paste0(geodata$config$mainfolder, "DIVA GIS/countries_shp/countries.shp"), layer="countries")
ISO3 <- as.character(boundaries$ISO3)
boundaries <- maptools::unionSpatialPolygons(boundaries, ISO3)
# save(boundaries, file=paste0(geodata$config$mainfolder, "cache/DIVA_GIS_boundaries.rda"))
}
}
return(boundaries)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.