Commit 9c90d07e authored by Renaud Lancelot's avatar Renaud Lancelot 🌍
Browse files

Add GIS admin layers for Africa.

parent dbb955bd
Pipeline #14815 passed with stage
in 7 minutes and 43 seconds
library(rgdal)
source("src/functions.R")
source("src/packages.R")
ctr <- c("Cameroon", "Central African Republic", "Chad", "Congo DR",
"Congo", "Equatorial Guinea", "Gabon", "Sao Tome and Principe",
"Benin", "Burkina Faso", "Cape Verde", "The Gambia", "Ghana",
"Guinea", "Guinea Bissau", "Cote d'Ivoire", "Liberia",
"Mali", "Mauritania", "Niger", "Nigeria", "Senegal", "Sierra Leone", "Togo")
ctry <- standardise_country_names(ctr)
codes <- ccodes()
Tcorresp <- subset(codes,
subset = NAME %in% ctry,
select = c("NAME", "ISO3"))
world <- readOGR(dsn = "d:/gis/gadm/gadm36_levels.gpkg",
layer = "level0")
wcAfrica1 <- world[world$GID_0 %in% Tcorresp$ISO3, ]
wcAfrica2 <- gSimplify(wcAfrica1,
tol=.025,
topologyPreserve=T)
wcAfrica3 <- as(wcAfrica2,
"SpatialPolygonsDataFrame")
wcAfrica3@data <- wcAfrica1@data
e <- extend(extent(wcAfrica3), 1)
E <- as(e, "SpatialPolygons")
projection(E) <- projection(wcAfrica1)
roi1 <- raster::intersect(world, E)
roi2 <- gSimplify(roi1,
tol=.025,
topologyPreserve=T)
roi3 <- as(roi2,
"SpatialPolygonsDataFrame")
roi3@data <- roi1@data
writeOGR(wcAfrica1,
dsn = "data/geoWCAfrica.gpkg",
layer = "geoWCAfrica",
driver = "GPKG", overwrite=T)
writeOGR(wcAfrica3,
dsn="data/geoWCAFricaLight.gpkg",
layer = "geoWCAFricaLight",
driver = "GPKG", overwrite=T)
writeOGR(roi1,
dsn = "data/roiWCAfrica.gpkg",
layer = "roiWCAfrica_WCAfricaWWWWWWWWWWWwwwWWW ",
driver = "GPKG",
overwrite = T)
writeOGR(roi3,
dsn = "data/roiWCAFricaLight.g_.......... pkg",
layer = "roiWCAFricaLight",
driver = "GPKG",
overwrite = T)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment