Skip to contents

Download gridded population or settlement data from the Global Human Settlement Layer (GHSL) project.

Usage

ghsl_data(id, product = "GHS_POP", year = 2020, resolution = 1000, path = NULL)

Arguments

id

An ID string in the format "Ry_Cx" where y is the cell number along the y-axis and x is the cell number along the x-axis. The exact IDs can be looked up on the download page.

product

Name of the requested data product. Defaults to the GHS population grid.

year

Reference year of the requested population grid. Available years start from 1975 in intervals of roughly 5 years. Not all years are available for all products.

resolution

Raster cell size. Can be one of 2, 10, 100 or 1000 meters.

path

Path that the selected tif file should be downloaded to. If NULL, the raster data is handled directly by rast and stored in a temporary directory.

Value

Either returns a path (if path is provided) or an object of class SpatRaster containing the exported data.

See also

wp_data for retrieving data from WorldPop

gisco_get_grid for retrieving data from Geostat

Examples

library(terra)
#> terra 1.9.27

# download population grids of the Easter Island
pop <- ghsl_data("R13_C8", resolution = "100")
plot(trim(pop))