Test (Spatial Analyst)
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
Usage
-
The test is specified by an SQL expression in the Where clause.
Syntax
Parameter | Explanation | Data Type |
in_raster |
The input raster on which the Boolean evaluation is performed, based on a logical expression. | Raster Layer |
where_clause | A logical expression that selects a subset of raster cells. The expression follows the general form of an SQL expression. Consult the documentation for more information on the SQL reference for query expressions used in ArcGIS and specifying a query in Python. | SQL Expression |
Return Value
Name | Explanation | Data Type |
out_raster |
The output raster. The output values will be either 0 or 1. | Raster |
Code Sample
This example uses a Where clause to perform a Boolean operation on an input raster.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outTest = Test("degs", "VALUE > 100")
outTest.save("C:/sapyexamples/output/outest.img")
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: Spatial Analyst Extension
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = "C:/sapyexamples/data"
# Set local variables
inRaster = "degs"
inWhereClause = "VALUE > 100"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute Test
outTest = Test(inRaster, inWhereClause)
# Save the output
outTest.save("C:/sapyexamples/output/outtest")