process_pop: Process Population Raster

process_popR Documentation

Process Population Raster

Description

Internal function used to process the population raster and copy it to its corresponding process folder

Usage

process_pop(
  mainPath,
  location,
  border,
  epsg,
  mostRecent,
  defaultMethods,
  changeRes,
  newRes,
  popCorrection,
  gridRes,
  alwaysProcess,
  allowInteractivity,
  testMode
)

Arguments

mainPath

character; the parent directory of the location name folder

location

character; the location name

border

sf object; a boundary shapefile

epsg

character; string that can be used as input in raster::crs() to describe a projection and datum

mostRecent

logical; should the most recent input be selected? If FALSE and if there are multiple available inputs, the user is interactively asked to select the input based on file creation time.

defaultMethods

logical; should be the default methods be used for projecting and resampling, respectively. These are the 'bilinear' method for projecting and the 'sum' or the 'bilinear' for the resampling, depending on if the new resolution is lower or higher.

changeRes

logical; does the user want to change the raster resolution? If NULL, the resolution is printed and it is interactively asked the user if they want to change it. IF FALSE, there is no resampling.

newRes

numeric; new resolution in meters. Ignored if the newRes is FALSE. If NULL and if changeRes is TRUE, the user is interactively asked to provide the new resolution.

popCorrection

logical; should the raster correction algorithm be run. If it is NULL, the user is interactively asked whether they want to run it or not.

gridRes

numeric; the resolution of the grid shapefile used for correcting the raster. Ignored if popCorrection is FALSE. If NULL and popCorrection is TRUE, the user is interactively asked to provide the grid resolution.

alwaysProcess

logical; if TRUE, the user is not asked if they want to process an input already processed.

allowInteractivity

logical; if TRUE, the user can choose the label for the processed layer. If FALSE, default label is used ('pr')

testMode

logical; used for testing. If TRUE labels of processed population layer is not interactively asked.

Details

The algorithm for correcting the population raster works as following: it creates a grid shapefile, it sums up the population in each of the cell considering both the 'raw' and the 'processed' population raster. Then a ratio is calculated between both values and related to each grid cell. The grid shapefile is rasterized using the ratios as values, and finally the 'processed' raster is multiplied by the rasterized ratio. The lower is the grid resolution, the finer is the correction.

Value

a list of length 2; The first element is the processed SpatRaster object and the second element is the selected projection method (for track record)


ptimoner/inAccMod documentation built on Jan. 27, 2025, 9:34 a.m.