prepare_data: Function to extract values from high-resolution covariates...

View source: R/as_disag.R

prepare_dataR Documentation

Function to extract values from high-resolution covariates and join to low-resolution polygon data This function is mostly taken from the disaggregation package

Description

Function to extract values from high-resolution covariates and join to low-resolution polygon data This function is mostly taken from the disaggregation package

Usage

prepare_data(
  polygon_shapefile,
  covariate_rasters,
  aggregation_raster = NULL,
  id_var = "area_id",
  response_var = "response",
  sample_size_var = NULL,
  na.action = FALSE
)

Arguments

polygon_shapefile

sf object containing at least three columns: one with the geometried, one with the id for the polygons (id_var) and one with the response data (response_var); for binomial data, i.e survey data, it can also contain a sample size column (sample_size_var).

covariate_rasters

SpatRaster of covariate rasters to be used in the model.

aggregation_raster

SpatRaster to aggregate pixel level predictions to polygon level e.g. population to aggregate prevalence. If this is not supplied a uniform raster will be used.

id_var

Name of column in sf object with the polygon id.

response_var

Name of column in sf object with the response data.

sample_size_var

For survey data, name of column in sf object (if it exists) with the sample size data.

na.action

logical. If TRUE, NAs in response will be removed, covariate NAs will be given the median value, aggregation NAs will be set to zero. Default FALSE (NAs in response or covariate data within the polygons will give errors).

Value

Returns a dataframe containing the values of covariates for each pixel with the associated polygon ID


timcdlucas/agouti documentation built on Feb. 8, 2024, 6:12 p.m.