Skip To Content

Pick (Spatial Analyst)

Available with Spatial Analyst license.

Available with Image Analyst license.

Summary

The value from a position raster is used to determine from which raster in a list of input rasters the output cell value will be obtained.

Illustration

Pick illustration
OutRas = Pick(InRas1, [InRas2, InRas3],"SINGLE_BAND")

Usage

  • The value of each cell of the Input position raster (in_position_raster in Python) determines which input will be used to obtain the output raster value. For example, if a cell in the Input position raster has a value of 1, the value from the first input in the raster list will be used for the output cell value. If the position input has a value of 2, the output value will come from the second input in the raster list, and so on.

  • The order of the Input rasters or constant values (in_rasters_or_constants in Python) is relevant for this tool. If the order of rasters changes, the results will change.

  • If a cell value Input position raster is zero or negative, the result will be NoData. If the position value is larger than the number of rasters in the list, the result will be NoData.

  • If the Input position raster is floating point, the values will be truncated to be integers before they are processed.

  • Any cell with a NoData value on the position raster will receive NoData on the output raster.

  • If any of the rasters in the input list is floating point, the output raster will be floating point. If they are all integer, the output raster will be integer.

  • How multiband rasters are handled depends on the settings of the Input position raster, Input rasters or constant values, and the Process as multiband (process_as_multiband in Python) parameters.

    To treat all bands from multiband input rasters equally, uncheck the Process as multiband parameter. This means any multiband rasters will be converted into multiple single-band rasters. The tool will then pick across all of the input bands and return the values based on the location specified in the Input position raster as a single-band output raster.

    To process a selection of bands from a multiband raster, first create a raster dataset composed of those particular bands with the Composite Bands tool. Use the result in the list of input rasters.

  • When one or many multiband rasters are specified as the Input rasters or constant values, and Process as multiband is checked, all multiband inputs will be processed as multiband.

    If the Input position raster is a single-band input, the output raster will have the maximum number of bands from the Input rasters or constant values.

    If the Input position raster is a multiband input, the output raster will have the same number of bands as the Input position raster.

    In both cases, the Input rasters or constant values will have as many virtual NoData bands added as needed to match the output band count.

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

Syntax

Pick(in_position_raster, in_rasters_or_constants, {process_as_multiband})
ParameterExplanationData Type
in_position_raster

Input raster defining the position of the raster to use for the output value.

The input can be an integer or float raster.

Raster Layer
in_rasters_or_constants
[in_raster_or_constant,...]

The list of inputs from which the output value will be selected.

The inputs can be integer or float rasters. A number can also be used as an input.

Raster Layer; Constant
process_as_multiband
(Optional)

Specifies how the input multiband raster bands are processed.

  • SINGLE_BANDMultiband inputs will be processed as a collection of single bands for in_rasters_or_constants. Only the first band of the in_position_raster multiband raster will be used to determine which position to pick. This will create a single-band output. This is the default.
  • MULTI_BANDMultiband inputs will be processed as multiband for in_rasters_or_constants.If the in_position_raster is a single-band input, the output raster will have the maximum number of bands from the in_rasters_or_constants.If the in_position_raster is a multiband input, the output raster will have the same number of bands as the in_position_raster.In both cases, the in_rasters_or_constants will have as many virtual NoData bands added as needed to match the output band count.
Boolean

Return Value

NameExplanationData Type
out_raster

The output raster.

Raster

Code sample

Pick example 1 (Python window)

This example assigns the output value based on the order of several input rasters.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outPick = Pick("cost", ["degs", "negs", "fourgrd"], "SINGLE_BAND")
outPick.save("C:/sapyexamples/output/outpick.tif")
Pick example 2 (stand-alone script)

This example assigns the output value based on the order of several input rasters.

# Name: Pick_Ex_02.py
# Description: Assigns output values using one of a list of rasters
#              determined by the value of an input raster.
# 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
inPositionRas = "inzone_MB"
inRas01 = "Ras1_MB"
inRas02 = "Ras2_MB"
inRas03 = "Ras3_MB"

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

# Execute Pick
outPick = Pick(inPositionRaster, [inRas01, inRas02, inRas03], "MULTI_BAND")

# Save the output 
outPick.save("C:/sapyexamples/output/outpick")

Licensing information

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

Related topics