View source: R/prepare_exposure.R
| prepare_exposure | R Documentation |
This function prepares tabular population exposure data compatible with the attribute() and compare() functions,
based on gridded pollution concentration data and polygon data representing geographic units.
If population data is provided, the function calculates an average concentration value in each geographic unit
that is weighted with the population number at each location.
If no population data is provided, the function calculates the simple spatial average concentration in each geographic unit.
prepare_exposure(
poll_grid,
geo_units,
population = NULL,
pop_grid = NULL,
geo_id_micro = NULL,
geo_id_macro = NULL,
bin_width = 0.1
)
poll_grid |
|
geo_units |
|
population |
|
pop_grid |
|
geo_id_micro |
|
geo_id_macro |
|
bin_width |
|
This function returns a list containing:
1) main (list) containing the main results as vectors;
geo_id_micro of geo_id_macro (string column) containing the (higher-level) geographic IDs of the assessment
exposure_mean (numeric column) containing the (population-weighted) mean exposure
population_total (integer column) containing the total population in each geographic unit, if population data was provided
2) detailed (list) containing detailed (and interim) results.
Arno Pauwels & Liliana Vazquez Fernandez
# Goal: determine population-weighted mean PM2.5 exposure for several
# neighborhoods of Brussels (Belgium)
path <- system.file("extdata", "exdat_pwm_1.tif", package = "healthiar")
exdat_pwm_1 <- terra::rast(path)
pwm <- prepare_exposure(
poll_grid = exdat_pwm_1, # Formal class SpatRaster
geo_units = exdat_pwm_2, # sf of the geographic sub-units
population = sf::st_drop_geometry(exdat_pwm_2$population), # population per geographic sub-unit
geo_id_macro = sf::st_drop_geometry(exdat_pwm_2$region) # higher-level IDs to aggregate at
)
pwm$exposure_main # population-weighted mean exposures for the (higher-level) geographic units
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.