Raster Calculator

Function Description: Used to create and execute Map Algebra expressions within the tool.

How It Works

The Raster Calculator tool is used to create and execute Map Algebra expressions within the tool.

The Raster Calculator tool offers the following advantages:

  • Executes single-line algebraic expressions.
  • Applies operations to three or more inputs within a single expression.

The Raster Calculator allows for the execution of single-line algebraic expressions using a variety of tools and operators. When multiple tools or operators are used within a single expression, the formula generally executes faster compared to executing each operator or tool separately.

Use the Raster Calculator tool

The tool dialog box contains three main areas for creating Map Algebra expressions: Raster Bands, Tools, and the expression box.

Picture

Raster Calculator

Raster Bands

The Raster Bands input list identifies the inputs available for use in Map Algebra expressions. The raster band list includes items added via the Open Raster button and raster layers from datasets.

Note: LiDAR360MLS currently supports raster operations only between raster bands. In expressions, raster bands are presented in the format: "DataName(without extension)@Number". Data identifiers are enclosed in double quotes, and raster bands are indexed starting from 1. For datasets with multiple bands, multiple entries such as Data@1, Data@2, and Data@3 will appear for the same dataset.

Tools

In the Tools list, you can select tools available for use in Map Algebra expressions. When you double-click a tool from the list, its name along with parentheses () will be placed at the current cursor position in the expression. You must then input the remaining required arguments for the tool. Tools can be placed anywhere in the expression, but their placement must adhere to valid Map Algebra syntax.

Operators in the list allow you to input mathematical (e.g., addition, division) and logical (e.g., greater than, equal to) operators into the expression. When selected, these symbols are inserted at the current cursor position in the expression.

Expression

The expression is the Map Algebra expression to be executed. The expression must be entered using valid syntax. For detailed information on the rules of Map Algebra syntax, refer to the following sections.

Map Algebra language

Map Algebra is a simple yet powerful algebraic language that allows you to use operators, functions, conditional statements, and more to perform various types of geographic analysis.

The Map Algebra used in the Raster Calculator includes a syntax or set of rules that must be followed to create valid expressions. Failure to adhere to these rules may result in invalid expressions that cannot be executed or lead to unexpected results.

Data Description

  • The Raster Calculator tool is used to create and execute Map Algebra expressions that output a raster.
  • Use the Raster Bands list to select the raster bands for use in the expression. The Tools list provides a set of commonly used conditional analysis tools and mathematical tools for easy addition to the expression. Numeric values (and mathematical operators) can be directly added to the expression.
  • Numeric values and scalars can be directly input into the expression.
  • During computation, the data range and coordinate system of the first raster in the expression will be used as the reference. If multiple datasets are present with inconsistent data ranges or coordinate systems, causing no overlap between the datasets, the calculation may fail.
  • When multiple relational operators and/or Boolean operators are used consecutively in a single expression, execution may fail in some cases. To avoid this potential issue, use appropriate parentheses in the expression to explicitly define the order of operator execution.
  • When multiple operators are used in an expression, operators are not necessarily executed in left-to-right order. Operators with higher precedence values will execute first. Parentheses can be used to control the execution order.
  • Boolean operators (~, &, ^, |) have a higher precedence than relational operators (<, <=, >, >=, ==, !=). Therefore, when Boolean operators are used as relational operators within the same expression, the Boolean operators will be executed first. To alter the execution order, use parentheses.
  • An example of operators and functions used in the Raster Calculator tool dialog box is shown below:
Category Operators and Functions Description Usage Example
Operators + Add the values of two rasters pixel by pixel (sum). "t_ras@1" + "s_ras@1"
- Subtract the values of the second raster from the first raster pixel by pixel. "t_ras@1" - "s_ras@1"
* Multiply the values of two rasters pixel by pixel. "t_ras@1" * "s_ras@1"
/ Divide the values of the two rasters pixel by pixel. "t_ras@1" / "s_ras@1"
= If the pixel value equals a specified value, return 1, otherwise return 0. ("t_ras@1" = 1) Or ("t_ras@1" = 2)
> If the value of the first raster is greater than the value of the second raster, return 1, otherwise return 0. "t_ras@1" > 100
< If the value of the first raster is less than the value of the second raster, return 1, otherwise return 0. "t_ras@1" < 100
<=< td=""> If the value of the first raster is less than or equal to the value of the second raster, return 1, otherwise return 0. "t_ras@1" <= 100<="" td="">
>= If the value of the first raster is greater than or equal to the value of the second raster, return 1, otherwise return 0. "t_ras@1" >= 100
!= If the value of the first raster is not equal to the value of the second raster, return 1, otherwise return 0. "t_ras@1" != 100
And Perform a "Boolean AND" operation on the pixel values of two input rasters. If both input values are true (non-zero), the output value is 1. If one or both input values are false (zero), the output value is 0. ("t_ras@1" = 1) And ("s_ras@1" > 100)
Or Perform a "Boolean OR" operation on the pixel values of two input rasters. If one or both input values are true (non-zero), the output value is 1. If both input values are false (zero), the output value is 0. ("t_ras@1" = 1) Or ("t_ras@1" = 2)
Not Perform a "Boolean NOT" (negation) operation on the pixel values of the input raster. If the input value is true (non-zero), the output value is 0. If the input value is false (zero), the output value is 1. Not("t_ras@1")
Xor Perform a "Boolean XOR" operation on the pixel values of two input rasters. If one input value is true (non-zero) and the other is false (zero), the output value is 1. If both input values are either true or false, the output value is 0. Xor("t_ras@1","s_ras@1")
Conditional Analysis If Perform an if/else conditional evaluation for each pixel in the input raster. If("t_ras@1" > 100,100,5)
Con Perform a similar if/else conditional evaluation for each pixel in the input raster. Con("t_ras@1" >= 10,10,1)
SetNull Set the identified pixel locations to NoData based on the specified condition. If the condition evaluates to true, return NoData; otherwise, return a value specified by another raster. SetNull("t_ras@1","s_ras@1","t_ras@1")
IsNull Determine which pixel values in the input raster are NoData. If the input value is NoData, return 1; otherwise, return 0. Con(IsNull("t_ras@1"),0,"s_ras@1")
Mathematical Analysis Abs Calculate the absolute value of the pixel values in the raster. Abs("t_ras@1")
Negate Change the sign of the pixel values in the input raster (multiply by -1) pixel by pixel. Negate("t_ras@1")
Exp Calculate the exponential of each pixel in the raster with base e. Exp("t_ras@1")
Exp10 Calculate the exponential of each pixel in the raster with base 10. Exp10("t_ras@1")
Exp2 Calculate the exponential of each pixel in the raster with base 2. Exp2("t_ras@1")
Float Convert each pixel value in the raster to a floating-point representation. Float("t_ras@1")
Int Convert each pixel value in the raster to an integer by truncation. Int("t_ras@1")
Ln Calculate the natural logarithm (base e) of each pixel in the raster. Ln("t_ras@1")
Log10 Calculate the logarithm of each pixel in the raster with base 10. Log10("t_ras@1")
Log2 Calculate the logarithm of each pixel in the raster with base 2. Log2("t_ras@1")
Mod Calculate the remainder (modulus) of dividing the first raster by the second raster pixel by pixel. Mod("t_ras@1")
Power Perform an exponentiation operation on the pixel values in another raster and use the result as the value for the raster. Power("t_ras@1")
RoundDown Return the nearest smaller integer value for each pixel in the raster (as a floating-point value). RoundDown("t_ras@1")
RoundUp Return the nearest larger integer value for each pixel in the raster (as a floating-point value). RoundUp("t_ras@1")
Square Calculate the square of each pixel value in the raster. Square("t_ras@1")
SquareRoot Calculate the square root of each pixel value in the raster. SquareRoot("t_ras@1")
Trigonometric Functions ACos Calculate the arccosine of each pixel in the raster. ACos("t_ras@1")
ACosH Calculate the inverse hyperbolic cosine of each pixel in the raster. ACosH("t_ras@1")
ASin Calculate the arcsine of each pixel in the raster. ASin("t_ras@1")
ASinH Calculate the inverse hyperbolic sine of each pixel in the raster. ASinH("t_ras@1")
ATan Calculate the arctangent of each pixel in the raster. ATan("t_ras@1")
ATan2 Calculate the arctangent of each pixel in the raster (based on x, y). ATan2("t_ras@1")
ATanH Calculate the inverse hyperbolic tangent of each pixel in the raster. ATanH("t_ras@1")
Cos Calculate the cosine of each pixel in the raster. Cos("t_ras@1")
CosH Calculate the hyperbolic cosine of each pixel in the raster. CosH("t_ras@1")
Sin Calculate the sine of each pixel in the raster. Sin("t_ras@1")
SinH Calculate the hyperbolic sine of each pixel in the raster. SinH("t_ras@1")
Tan Calculate the tangent of each pixel in the raster. Tan("t_ras@1")
TanH Calculate the hyperbolic tangent of each pixel in the raster. TanH("t_ras@1")

Steps

  1. Go to Toolbox -> Raster Tools -> Raster Analysis -> Raster Calculator tool, and double-click to open the tool dialog.

Picture

Raster Calculator

</div> Parameter Description:

  • Raster Band: The raster band data that will be used in the calculation. This data can either come from the current project or be added by opening a file.
  • Tools: Includes all operators, conditional analysis, mathematical analysis, trigonometric functions, etc. Double-clicking on an item automatically adds it to the expression box.
  • Output Raster: The raster that will store the result of the calculation. The pixel type of this raster is determined based on the result type of the expression.
  • Add Result to Project: If checked, a layer for the result data will be automatically created and added to the project.

results matching ""

    No results matching ""