Extract by Attributes

Extracts the cells of a raster based on a logical query.


Illustration

Extract by Attributes illustration

Usage tips

Command line and Scripting

Syntax

ExtractByAttributes_sa (in_raster, where_clause, out_raster)
Parameter Explanation Datatype
in_raster (Required)

The input raster from which cells will be extracted.

Composite Geodataset
Where clause (Required)

An SQL expression used to select a subset of raster cells.

For information on SQL syntax, see SQL Reference.

SQL Expression
Output raster (Required)

The raster to be created.

Raster Dataset
Data types for geoprocessing tool parameters

Script Example

# ExtractByAttributes_sample.py
# Description:
#   Extracts the cells of a raster based on a logical query.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005

# Import system modules
import arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

try:
    # Set local variables
    InRaster = "C:/data/raster1"
    InWhereClause = "value <= 35"
    OutRaster = "C:/data/final_1"

    # Check out Spatial Analyst extension license
    gp.CheckOutExtension("Spatial")

    # Process: ExtractByAttributes
    gp.ExtractByAttributes_sa(InRaster, InWhereClause, OutRaster)

except:
    # If an error occurred while running a tool, then print the messages.
    print gp.GetMessages()

Map Algebra syntax

See Select


ArcObjects syntax

See Attribute


See Also

  • Extract by Circle
  • Extract by Mask
  • Extract by Polygon
  • Extraction by specified locations - sampling
  • An overview of the Extraction tools