eval_pgap: Calculate probability gap

View source: R/dsmartr_evaluate.R

eval_pgapR Documentation

Calculate probability gap

Description

Calculates and maps the difference between the first and second most-probable dsmartr probability surfaces. Requires outputs of dsmartr::collate().

Usage

eval_pgap(dsmartr_probs = NULL, cpus = 1)

Arguments

dsmartr_probs

RasterBrick; 'dsmartr_probabilities' output by dsmartr::collate(). Alternatively, probability maps output by dsmartr::most_likely() can be used, or a list of two rasters read from disk.

cpus

Integer; number of processors to use in parallel.

Value

probability_gap: RasterLayer depicting the probability gap. Written to disk as GeoTIFF.

Note

This function is often called the 'confusion index', but has been renamed as that term is used in multiple contexts within the scientific literature.

Examples

## Not run: 
# run collate() with the example data then:
pgap1 <-
  eval_pgap(dsmartr_probs = collated[['dsmartr_probabilities']][[1:2]],
  cpus = max(1, (parallel::detectCores() - 1)))

# or supply unstacked maps after running unstack() (slightly faster)
pgap2 <- eval_pgap(dsmartr_probs = most_likely_soil[c('most_likely_prob_1',
                                                      'most_likely_prob_2')],
                   cpus = max(1, (parallel::detectCores() - 1)))

# or read from file
mpp_1 <- raster(file.path(getwd(), 'most_likely_maps', 'most_likely_1.tif'))
mpp_2 <- raster(file.path(getwd(), 'most_likely_maps', 'most_likely_2.tif'))
pgap3 <- eval_pgap(dsmartr_probs = list(mpp_1, mpp_2),
                   cpus = max(1, (parallel::detectCores() - 1)))

## End(Not run)

obrl-soil/dsmartr documentation built on Feb. 1, 2024, 10:57 p.m.