> library(sp)
> library(raster)
> library(ecomore)
100m-resolution raster files of population size in 2010 and 2015, raw and adjusted, from WorldPop:
> LAO_popmap10_admin001 <- raster("data-raw/Lao_People_s_Democratic_Republic_100m_Population/LAO_popmap10_admin001_v2.tif")
> LAO_popmap10adj_admin001 <- raster("data-raw/Lao_People_s_Democratic_Republic_100m_Population/LAO_popmap10adj_admin001_v2.tif")
> LAO_popmap15_admin001 <- raster("data-raw/Lao_People_s_Democratic_Republic_100m_Population/LAO_popmap15_admin001_v2.tif")
> LAO_popmap15adj_admin001 <- raster("data-raw/Lao_People_s_Democratic_Republic_100m_Population/LAO_popmap15adj_admin001_v2.tif")
90m-resolution raster files of urban changes in 2000 and 2010, from WorldPop:
> LAO00urbchg <- raster("data-raw/Lao_People_s_Democratic_Republic_100m_Urban_change/LAO00urbchg.tif")
> LAO10urbchg <- raster("data-raw/Lao_People_s_Democratic_Republic_100m_Urban_change/LAO10urbchg.tif")
Downloading province and district polygons from GADM, if not available on the disk:
> for (i in 1:2) {
+ file <- paste0("gadm36_LAO_", i, "_sp.rds")
+ if (! file.exists(file))
+ download.file(paste0("https://biogeo.ucdavis.edu/data/gadm3.6/Rsp/", file), paste0("data-raw/", file))
+ }
Loading the provinces’ polygons:
> gadm36_LAO_1 <- readRDS("gadm36_LAO_1_sp.rds")
Extracting the polygon of Vientiane prefecture:
> vientiane <- gadm36_LAO_1[gadm36_LAO_1$NAME_1 == "Vientiane [prefecture]", ]
Croping the populations raster files:
> VT_popmap10_admin001 <- crop_raster(LAO_popmap10_admin001, vientiane)
> VT_popmap10adj_admin001 <- crop_raster(LAO_popmap10adj_admin001, vientiane)
> VT_popmap15_admin001 <- crop_raster(LAO_popmap15_admin001, vientiane)
> VT_popmap15adj_admin001 <- crop_raster(LAO_popmap15adj_admin001, vientiane)
> VT00urbchg <- crop_raster(LAO00urbchg, vientiane)
> VT10urbchg <- crop_raster(LAO10urbchg, vientiane)
Writing to disk:
> if (!dir.exists("data")) dir.create("data")
> writeRaster(VT_popmap10_admin001, "data/VT_popmap10_admin001.tif", "GTiff", overwrite = TRUE)
> writeRaster(VT_popmap10adj_admin001, "data/VT_popmap10adj_admin001.tif", "GTiff", overwrite = TRUE)
> writeRaster(VT_popmap15_admin001, "data/VT_popmap15_admin001.tif", "GTiff", overwrite = TRUE)
> writeRaster(VT_popmap15adj_admin001, "data/VT_popmap15adj_admin001.tif", "GTiff", overwrite = TRUE)
> writeRaster(VT00urbchg, "data/VT00urbchg.tif", "GTiff", overwrite = TRUE)
> writeRaster(VT10urbchg, "data/VT10urbchg.tif", "GTiff", overwrite = TRUE)