Retrieve gridded population data from the WorldPop API.
Select which data to download using
wp_categories,wp_projects, andwp_datasetsRetrieve metadata about datasets using
wp_metaDownload gridded data using
wp_data
Usage
wp_categories()
wp_projects(category = "pop")
wp_datasets(category = "pop", project = "wpic1km")
wp_meta(
id = NULL,
country = NULL,
year = NULL,
category = "pop",
project = "wpic1km"
)
wp_data(
country = NULL,
year = "latest",
id = NULL,
category = "pop",
project = "wpic1km",
path = NULL
)Arguments
- category
Alias of a dataset returned by
worldpop_datasets. Defaults to"pop"(population counts).- project
Alias of a dataset returned by
worldpop_projects. Defaults to"wpic1km"(unconstrained individual countries at a 1km resolution).- id
ID of a dataset as returned by
worldpop_levels. Can be used to identify a single dataset.- country
ISO-3 country code as returned by
worldpop_levels. Used to download the gridded data for a specific country.- year
Reference year of the requested population grid as returned by
worldpop_levels.- path
Path that the selected tif file should be downloaded to. If
NULL, the raster data is handled directly byrastand stored in a temporary directory.
Value
wp_categoriesandwp_projectsreturn dataframes of data categories and projects within these categories, respectively, including their names, descriptions, and aliases.wp_datasetsreturns a dataframe containing all datasets of a project including their IDs, titles, years and ISO-3 country codes.wp_metareturns a dataframe containing metadata about selected datasets.wp_dataeither returns a path (ifpathis provided) or an object of classSpatRastercontaining the exported data.
See also
ghsl_data for retrieving data from Global Human Settlement Layer
gisco_get_grid for retrieving data from Geostat
Examples
# inspect categories
wp_categories()
#> # A tibble: 18 × 4
#> alias name title desc
#> <chr> <chr> <chr> <chr>
#> 1 pop Population Counts Population Counts "<b>…
#> 2 births Births Births "The…
#> 3 pregnancies Pregnancies Pregnancies "The…
#> 4 urban_change Urban change Urban change "Eas…
#> 5 age_structures Age and sex structures Age and sex structu… "<b>…
#> 6 dahi Development Indicators Development and Hea… "Imp…
#> 7 dependency_ratios Dependency Ratios Dependency Ratios "The…
#> 8 internal_migration_f Migration Flows Migration Flows "Hum…
#> 9 dynamic_mapping Dynamic Mapping Dynamic Mapping "Kno…
#> 10 global_flight_data Global Flight Data Global Flight Data "The…
#> 11 covariates Covariates Geospatial covariat… "<b>…
#> 12 gbsg Global Settlement Growth Global Built-Settle… "Cha…
#> 13 gridcellsurfaceareas Grid-cell surface areas Grid-cell surface a… "Gri…
#> 14 adminareas Administrative Areas Administrative Areas "Adm…
#> 15 pop_density Population Density Population Density "<b>…
#> 16 pwd Population Weighted Density Population Weighted… "<b>…
#> 17 future_pop Future Population Projections Future Population P… "Thi…
#> 18 dug Degree of Urbanisation Degree of Urbanisat… "The…
# inspect projects within the "pop" category
wp_projects("pop")
#> # A tibble: 17 × 2
#> alias name
#> <chr> <chr>
#> 1 "pic" "Individual countries"
#> 2 "pop_continent" "Whole Continent"
#> 3 "wpgp" "Unconstrained individual countries 2000-2020 ( 100m r…
#> 4 "wpgp1km" "Unconstrained global mosaics 2000-2020 ( 1km resoluti…
#> 5 "" "WP00643"
#> 6 "wpgpunadj" "Unconstrained individual countries 2000-2020 UN adjus…
#> 7 "wpic1km" "Unconstrained individual countries 2000-2020 ( 1km r…
#> 8 "wpicuadj1km" "Unconstrained individual countries 2000-2020 UN adjus…
#> 9 "cic2020_100m" "Constrained Individual countries 2020 ( 100m resoluti…
#> 10 "cic2020_UNadj_100m" "Constrained Individual countries 2020 UN adjusted (1…
#> 11 "G2_UC_POP_2024_100m" "Unconstrained individual countries 2024 ( 100m resolu…
#> 12 "G2_CN_POP_2024_100m" "Constrained individual countries 2024 ( 100m resoluti…
#> 13 "G2_UC_POP_R24B_100m" "Unconstrained individual countries 2015-2030 ( 100m r…
#> 14 "G2_CN_POP_R24B_100m" "Constrained individual countries 2015-2030 ( 100m res…
#> 15 "G2_CN_POP_R25A_100m" "Individual countries 2015-2030 ( 100m resolution ) R2…
#> 16 "G2_CN_POP_R25A_1km" "Individual countries 2015-2030 ( 1km resolution ) R20…
#> 17 "G2_MOS_POP_R25A_1km" "Global mosaics 2015-2030 ( 1km resolution ) R2025A v1"
# inspect datasets within the "wpic1km" project
wp_datasets("pop", project = "wpic1km")
#> # A tibble: 5,061 × 4
#> id title popyear iso3
#> <chr> <chr> <chr> <chr>
#> 1 29693 The spatial distribution of population in 2000 Russia 2000 RUS
#> 2 29694 The spatial distribution of population in 2001 Russia 2001 RUS
#> 3 29695 The spatial distribution of population in 2002 Russia 2002 RUS
#> 4 29696 The spatial distribution of population in 2003 Russia 2003 RUS
#> 5 29697 The spatial distribution of population in 2004 Russia 2004 RUS
#> 6 29698 The spatial distribution of population in 2005 Russia 2005 RUS
#> 7 29699 The spatial distribution of population in 2006 Russia 2006 RUS
#> 8 29700 The spatial distribution of population in 2007 Russia 2007 RUS
#> 9 29701 The spatial distribution of population in 2008 Russia 2008 RUS
#> 10 29702 The spatial distribution of population in 2009 Russia 2009 RUS
#> # ℹ 5,051 more rows
# retrieve metadata about the population grids in Samoa
wp_meta(country = "WSM")
#> # A tibble: 21 × 27
#> id title desc doi date popyear citation data_file archive public
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 34670 The spatia… Esti… 10.5… 2020… 2000 WorldPo… GIS/Popu… N Y
#> 2 34671 The spatia… Esti… 10.5… 2020… 2001 WorldPo… GIS/Popu… N Y
#> 3 34672 The spatia… Esti… 10.5… 2020… 2002 WorldPo… GIS/Popu… N Y
#> 4 34673 The spatia… Esti… 10.5… 2020… 2003 WorldPo… GIS/Popu… N Y
#> 5 34674 The spatia… Esti… 10.5… 2020… 2004 WorldPo… GIS/Popu… N Y
#> 6 34675 The spatia… Esti… 10.5… 2020… 2005 WorldPo… GIS/Popu… N Y
#> 7 34676 The spatia… Esti… 10.5… 2020… 2006 WorldPo… GIS/Popu… N Y
#> 8 34677 The spatia… Esti… 10.5… 2020… 2007 WorldPo… GIS/Popu… N Y
#> 9 34678 The spatia… Esti… 10.5… 2020… 2008 WorldPo… GIS/Popu… N Y
#> 10 34679 The spatia… Esti… 10.5… 2020… 2009 WorldPo… GIS/Popu… N Y
#> # ℹ 11 more rows
#> # ℹ 17 more variables: source <chr>, data_format <chr>, author_email <chr>,
#> # author_name <chr>, maintainer_name <chr>, maintainer_email <chr>,
#> # project <chr>, category <chr>, gtype <chr>, continent <chr>, country <chr>,
#> # iso3 <chr>, files <list>, url_img <chr>, organisation <chr>, license <chr>,
#> # url_summary <chr>
# download the population grid of Samoa in 2020
sam <- wp_data(country = "WSM", year = 2020)
library(terra)
plot(sam)
