ifelse | R Documentation |
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.
ifelse(condition, true_value, false_value, method = "arith")
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" |
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.
the true or false value matching the data type of the condition.
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.
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?.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.