preprocess_input {restoptr}R Documentation

Restopr input preprocessing function.

Description

From a binary, possibly high resolution, habitat raster, this function produces three input rasters for restopt:

Usage

preprocess_input(habitat, habitat_threshold = 1, aggregation_factor = 1)

Arguments

habitat

terra::rast() Raster object containing binary values that indicate if each planning unit contains habitat or not. Cells with the value 1 must correspond to existing habitat. Cells with the value 0 must correspond to degraded (or simply non-habitat) areas. Finally, NA (or NO_DATA) cells are considered to be outside of the landscape.

habitat_threshold

numeric Number between 0 and 1 indicating, when the habitat raster is downsampled, the minimum proportion of habitat cells (from the original raster) are required within the downsampled raster to be considered as habitat.

aggregation_factor

integer positive integer corresponding to the level of downsampling that will be applied to the habitat. This parameter is important to ensure the tractability of a problem.

Details

This preprocessing function produces the necessary inputs of a restopt problem from a single binary habitat raster (habitat), which can be at high resolution. Restopt solves a hard constrained combinatorial problem (it can be reduced to a constrained 0/1 knapsack problem, which is know to be NP-Complete), thus the input resolution might need to be reduced to ensure a tractable problem. Performing this downsampling in a systematic and reproducible way is the aim of this function, which relies on the terra::aggregate() function to do it. The aggregation_factor parameter indicates how much the resolution must be reduced. An aggregated pixel will contain at most aggregation_factor^2 pixels from the input habitat raster (cell_area raster in this function outputs). If an aggregated pixel is close to the spatial boundaries of the problem (i.e. NA cells), it can contain less than aggregation_factor^2 fine grained pixels. The habitat_threshold parameter indicates the minimum proportion of habitat pixels (relative to cell_area) whose value is 1 to consider an aggregated pixel as habitat (downsampled_habitat output raster). The restorable_area output raster correspond to the number of pixel with value 0 in aggregated pixels.

Value

A list : list( existing_habitat=downsampled_habitat, restorable_habitat=restorable_habitat, cell_area=cell_area )

Examples


# load data
habitat_data <- rast(
  system.file("extdata", "habitat_hi_res.tif", package = "restoptr"))
data <- preprocess_input(
    habitat = habitat_data,
    habitat_threshold = 0.7,
    aggregation_factor = 16
)



[Package restoptr version 1.0.6 Index]