ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Test

Available with Spatial Analyst license.

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code Sample
  • Environments
  • Licensing Information

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 the Query Builder:

    • Building a query expression
    • SQL reference for query expressions used in ArcGIS

  • 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.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Syntax

Test (in_raster, where_clause)
ParameterExplanationData 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 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.sa import *
env.workspace = "C:/sapyexamples/data"
outTest = Test("degs", "VALUE > 100")
outTest.save("C:/sapyexamples/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: 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")

Environments

  • Auto Commit
  • Cell Size
  • Compression
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Mask
  • Output CONFIG Keyword
  • Output Coordinate System
  • Raster Statistics
  • Scratch Workspace
  • Snap Raster
  • Tile Size

Licensing Information

  • ArcGIS for Desktop Basic: Requires Spatial Analyst
  • ArcGIS for Desktop Standard: Requires Spatial Analyst
  • ArcGIS for Desktop Advanced: Requires Spatial Analyst

Related Topics

  • An overview of the Math toolset
  • An overview of the Logical Math tools
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal