This function takes vectors of sampling site longitude and latitude and calculates the total population residing within a given radius around each sampling site. Intermediate spatial variables are written to the directory specified in path_output.

get_population_radius(lon, lat, radius, path_pop_raster, path_output)

Arguments

lon

A numeric vector giving the longitudes of the sampling sites in Decimal Degrees.

lat

A numeric vector giving the latitudes of the sampling sites in Decimal Degrees.

radius

Numeric giving the radius (in meters) around each point to calculate total population

path_pop_raster

The file path to a raster object providing population counts in each grid cell. See download_worldpop_data for methods to download population raster data.

path_output

The file path of an output directory where spatial data will be saved.

Value

A data.frame containing the total population counts for the given radius around each sampling site.

Examples

if (FALSE) {

dir.create(file.path(getwd(), 'tmp'))

download_worldpop_data(iso3 = 'BGD',
                       year = 2020,
                       constrained = FALSE,
                       UN_adjusted = FALSE,
                       path_output = file.path(getwd(), 'tmp'))

get_population_radius(lon = template_es_data$lon,
                      lat = template_es_data$lat,
                      radius = 100,
                      path_pop_raster = file.path(getwd(), 'tmp/bgd_ppp_2020.tif'),
                      path_output = file.path(getwd(), 'tmp'))

}