popcompr
is an R package to make it easier different high resolution population datasets for humanitarian and research purposes. It is under active development and has not been released, but the code is available through a GPL3 license. See the documentation at https://mrajeev08.github.io/popcompr/.
You can install the development version of popcompr
using the remotes
package:
remotes::install_github("mrajeev08/popcompr")
Included in the package are two datasets on population estimates in Lesotho (simply choosing Lesotho because its small) downloaded from HDX. See ?lso_worlpop_2019
and ?lso_facebook_2019
for more details. You have to access them using the system.file arguments so that the functions can correctly work with the raster files stored on the disk.
This example compares these two datasets at a default resolution of 0.0833 degrees (or approximately 1 km2 at the equator):
library(popcompr) library(raster) # also need to load this for examples # comparing at pixel level with data included in the package lesotho_wp_2019 <- raster(system.file("external/lso_facebook_2019.tif", package="popcompr")) lesotho_fb_2019 <- raster(system.file("external/lso_worldpop_2019.tif", package="popcompr")) pop_list <- list(lesotho_wp_2019, lesotho_fb_2019) # compare pop function compare_pop(pop_list, parallel = FALSE)
You can also compare population estimates at the administrative level. Access to country shapefiles is provided through a wrapper to the geoBoundaries API. To see available datasets, use View(geoboundaries
)`. An example for Lesotho:
# Find the right iso code & see which admin levels are available dplyr::filter(geoboundaries, grepl("Les", country)) les_shape <- get_country_shape(country_iso = "LSO", admin_level = 2)
# get admin level comparison les_shape <- aggregate_to_shp(brick = exe, sf = les_shape, max_adjacent = 100)
See the documentation for examples of vizualizations.
Here are also some great resources on gridded population datasets from CIESIN at Columbia University: https://sedac.ciesin.columbia.edu/mapping/popgrid.
First clone the repo:
git clone https://github.com/mrajeev08/popcompr.git
Then navigate to the repo and build the image (might take a while if rocker/geospatial is not already built):
docker build . -t popcompr
Then run your container:
docker run -d -p 8787:8787 --name popcompr -e USER=mrajeev -e PASSWORD=pass popcompr:latest
Navigate to http://localhost:8787
in your browser and then use the username and password to use Rstudio.
This package is in it’s very starting stages. Here’s the planned/proposed dev.
data.table
& raster
(including conflict with shift
)data.table
with gmin
in match_nearest
iso_codes
to geoBoundaries_datamatch_nearest
to be faster and cleanerraster::canProcessInMemory
)