Test (Image Analyst)

Available with Spatial Analyst license.

Available with Image Analyst license.

Summary

Performs a Boolean evaluation of the input raster using a logical expression.

When the expression evaluates to true, the output cell value is 1. If the expression is false, the output cell value is 0.

Illustration

Test illustration
OutRas = Test(InRas1,"Value >= 2")

Usage

  • The test is specified by an SQL expression in the Where clause.

  • The Where clause uses an SQL query. See the following topics for more details on creating queries:

  • In order to use a {where_clause} in Python, it should be enclosed in quotes. For example, "Value > 5000".

    You can consult the help for more information on specifying a query in Python.

  • If the input is a multiband raster, the output will be a multiband raster. The tool will perform the operation on each band in the input.

  • In ArcPy, if the input is a multidimensional raster, all slices from all variables will be processed, and the output will be a multidimensional raster.

Parameters

LabelExplanationData Type
Input raster

The input raster on which the Boolean evaluation is performed, based on a logical expression.

Raster Layer
Where clause

The logical expression that will determine which input cells will return a value of true (1) and which will be false (0).

The Where clause follows the general form of an SQL expression. It can be entered directly, for example, VALUE > 100, if you click the Edit SQL mode button SQL Query. If in the Edit Clause Mode Edit Clause, you can begin constructing the expression by clicking on the Add Clause Mode button.

SQL Expression

Return Value

LabelExplanationData Type
Output raster

The output raster.

The output cell values will be either 0 or 1.

Raster

Test(in_raster, where_clause)
NameExplanationData Type
in_raster

The input raster on which the Boolean evaluation is performed, based on a logical expression.

Raster Layer
where_clause

The logical expression that will determine which input cells will return a value of true (1) and which will be false (0).

The expression follows the general form of an SQL expression. An example of a where_clause is "VALUE > 100".

SQL Expression

Return Value

NameExplanationData Type
out_raster

The output raster.

The output cell values will be either 0 or 1.

Raster

Code sample

Test example 1 (Python window)

This example uses a Where clause to perform a Boolean operation on an input raster.

import arcpy
from arcpy import env
from arcpy.ia import *
env.workspace = "C:/iapyexamples/data"
outTest = Test("degs", "VALUE > 100")
outTest.save("C:/iapyexamples/output/outest.img")
Test example 2 (stand-alone script)

This example uses a Where clause to perform a Boolean operation on an input raster.

# Name: Test_Ex_02.py
# Description: Perform a Boolean evaluation of the input raster based
#              on a where clause
# Requirements: Image Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.ia import *

# Set environment settings
env.workspace = "C:/iapyexamples/data"

# Set local variables
inRaster = "degs"
inWhereClause = "VALUE > 100"

# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")

# Execute Test
outTest = Test(inRaster, inWhereClause)

# Save the output 
outTest.save("C:/iapyexamples/output/outtest")

Licensing information

  • Basic: Requires Image Analyst or Spatial Analyst
  • Standard: Requires Image Analyst or Spatial Analyst
  • Advanced: Requires Image Analyst or Spatial Analyst

Related topics