# Goal: determine population-weighted mean PM2.5 exposure for several
# neighborhoods of Brussels (Belgium)
exdat_pwm_1 <- terra::rast(system.file("extdata", "exdat_pwm_1.tif", package = "healthiar"))
exdat_pwm_2 <- sf::st_read(
system.file("extdata", "exdat_pwm_2.gpkg", package = "healthiar"),
quiet = TRUE
)
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$main # population-weighted mean exposures for the (higher-level) geographic units
Run the code above in your browser using DataLab