Create a Normalised Raster Aligned with and masked by Planning Units
make_normalised_raster.RdThis function takes an input raster, aligns it with specified planning units (PUs), optionally inverts, rescales, applies conditional expressions, and saves the processed raster to a specified output path.
Usage
make_normalised_raster(
raster_in,
pus,
iso3,
invert = FALSE,
rescaled = TRUE,
method_override = NULL,
crop_global_input = TRUE,
input_raster_conditional_expression = NULL,
conditional_expression = NULL,
fill_na = 0,
name_out,
output_path = NULL,
threads = TRUE
)Arguments
- raster_in
SpatRasterThe input raster to be processed.- pus
SpatVectorThe planning units (PUs) to align the raster to.- iso3
characterISO3 country code used for naming the output file.- invert
logicalIfTRUE, inverts the raster values (default:FALSE).- rescaled
logicalIfTRUE, rescales the raster usingrescale_raster()(default:TRUE).- method_override
characterOptional method forterra::project(), overriding the default (default:NULL).- crop_global_input
logicalIf true the input (large global) raster is cropped to the PU extent before applying aninput_raster_conditional_expression, to reduce the are of processing (default:TRUE).- input_raster_conditional_expression
functionOptional method to apply a function to the raster before resampling to the PU layer (default:NULL).- conditional_expression
functionOptional method to apply a function to the raster after resampling to the PU layer (default:NULL).- fill_na
numericorNAThe fill value to use to fill inNAvalues before masking (default: 0).- name_out
characterThe name of the output raster file (without the extension).- output_path
characterThe directory path to save the output raster (default:NULL, i.e., not saved).- threads
Optional method to use multi-core processing - to speed on some
terrafunctions (default:TRUE).
Value
Returns a SpatRaster object that has been reprojected and processed.
If output_path is specified, saves the raster as a COG (Cloud Optimized GeoTIFF).
Details
This function reprojects the input raster (raster_in) to match the CRS and resolution
of the planning units (pus). The method for reprojection can be overridden using method_override.
If input_raster_conditional_expression is provided, it is applied before any reprojection. Applying a
input_raster_conditional_expression can also make processing times significantly longer
for high resolution input rasters.The function can optionally rescale (0-1) and invert the raster values.