Commit 69339e75 authored by Renaud Lancelot's avatar Renaud Lancelot 🌍
Browse files

R code to produce later-used GPKG files from GADM

parent 51107d57
library(rgdal)
library(sp)
library(raster)
library(rgeos)
ctry <- standardise_country_names(c(eu28, efta, noneu))
codes <- ccodes()
Tcorresp <- subset(codes,
subset = NAME %in% ctry,
select = c("NAME", "ISO3"))
world <- readOGR(dsn = "d:/gis/gadm/gadm36_levels.gpkg",
layer = "level0")
euro1 <- world[world$GID_0 %in% Tcorresp$ISO3, ]
euro2 <- gSimplify(euro1,
tol=.025,
topologyPreserve=T)
euro3 <- as(euro2,
"SpatialPolygonsDataFrame")
euro3@data <- euro1@data
e <- extend(extent(euro3), 1)
E <- as(e, "SpatialPolygons")
projection(E) <- projection(euro1)
roi1 <- raster::intersect(world, E)
roi2 <- gSimplify(roi1,
tol=.025,
topologyPreserve=T)
roi3 <- as(roi2,
"SpatialPolygonsDataFrame")
roi3@data <- roi1@data
writeOGR(euro1,
dsn="geo_europe.gpkg",
layer = "geo_europe",
driver="GPKG", overwrite=T)
writeOGR(euro3,
dsn="data/geo_europe_light.gpkg",
layer = "geo_europe_light",
driver = "GPKG", overwrite=T)
writeOGR(roi1,
dsn="data/roi_europe.gpkg",
layer = "roi_europe",
driver="GPKG",
overwrite=T)
writeOGR(roi3,
dsn="data/roi_europe_light.gpkg",
layer = "roi_europe_light",
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