Skip to contents

WorldPop, which was initiated in 2013, offers easy access to spatial demographic datasets, claiming to use peer-reviewed and fully transparent methods to create global mosaics for the years 2000 to 2020. This function allows to efficiently calculate population count statistics (e.g. total number of population) for polygons. For each polygon, the desired statistic/s (min, max, sum, mean, median, sd or var) is/are returned.

Usage

calc_population_count(engine = "extract", stats = "sum")

Arguments

engine

The preferred processing functions from either one of "zonal", "extract" or "exactextract" as character.

stats

Function to be applied to compute statistics for polygons either one or multiple inputs as character "min", "max", "sum", "mean", "median" "sd" or "var".

Value

A function that returns tibble with a column for population count statistics.

Details

The required resources for this indicator are:

Examples

# \dontshow{
mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data"))
# }
# \dontrun{
library(sf)
library(mapme.biodiversity)

outdir <- file.path(tempdir(), "mapme-data")
dir.create(outdir, showWarnings = FALSE)

mapme_options(
  outdir = outdir,
  verbose = FALSE
)

aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg",
  package = "mapme.biodiversity"
) %>%
  read_sf() %>%
  get_resources(get_worldpop(years = 2000:2010)) %>%
  calc_indicators(
    calc_population_count(engine = "extract", stats = c("sum", "median"))
  ) %>%
  tidyr::unnest(population_count)

aoi
#> Simple feature collection with 11 features and 8 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -71.80933 ymin: 18.57668 xmax: -71.33201 ymax: 18.69931
#> Geodetic CRS:  WGS 84
#> # A tibble: 11 × 9
#>    WDPAID NAME            DESIG_ENG     ISO3  assetid population_count_sum
#>     <dbl> <chr>           <chr>         <chr>   <int>                <dbl>
#>  1 478140 Sierra de Neiba National Park DOM         1                3941.
#>  2 478140 Sierra de Neiba National Park DOM         1                3786.
#>  3 478140 Sierra de Neiba National Park DOM         1                4012.
#>  4 478140 Sierra de Neiba National Park DOM         1                4083.
#>  5 478140 Sierra de Neiba National Park DOM         1                4336.
#>  6 478140 Sierra de Neiba National Park DOM         1                4323.
#>  7 478140 Sierra de Neiba National Park DOM         1                4569.
#>  8 478140 Sierra de Neiba National Park DOM         1                4339.
#>  9 478140 Sierra de Neiba National Park DOM         1                4784.
#> 10 478140 Sierra de Neiba National Park DOM         1                4923.
#> 11 478140 Sierra de Neiba National Park DOM         1                4016.
#> # ℹ 3 more variables: population_count_median <dbl>, year <chr>,
#> #   geom <POLYGON [°]>
# }