ifelse: Raster Con Function

View source: R/ifelse.R

ifelseR Documentation

Raster Con Function

Description

This function is designed to behave similar to the ESRI Spatial Analyst Con function. The purpose of this function is to provide R with a raster safe ifelse function.

Usage

ifelse(condition, true_value, false_value, method = "arith")

Arguments

condition

raster or numeric; an expression that results in a boolean, matching the type of the condition.

true_value

raster, constant; Input true raster or constant value.

false_value

raster, constant; Input false raster or constant value.

method

character; Method for calculating the output raster. One of: "arith", "overlay"

Details

The R raster world has long lacked an efficient equivalent to the ESRI Con function. Benchmarking is necessary to determine the efficiency of these various methods for conplex expressions on large real-world rasters.

Value

the true or false value matching the data type of the condition.

method = "arith"

The functional form of the method = "arith" was proposed by Spacedman on gis.stackexchange way back in 2013, What is the equivalent of arcpy "Con" in QGIS and/or R raster-package?. The implementation of this method uses the raster Arith-methods using standard arithmetic operators on rasters.

method = "overlay"

The raster package documentation suggests that the overlay function may be faster for large rasters and complex functions than the Arith-methods. Also see: Raster ifelse conditional in R?.


MVR-GIS/nybem documentation built on Feb. 9, 2023, 7:03 a.m.