Pick (Image Analyst)

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 on the 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.

  • If the Process as multiband parameter is unchecked (process_as_multiband is set to SINGLE_BAND in Python), only the first band of a multiband Input position raster (in_position_raster in Python) will be used. Each band from a multiband Input rasters or constant values (in_rasters_or_constants in Python) will be processed separately as a single-band raster.

  • If the Process as multiband parameter is checked (process_as_multiband is set to MULTI_BAND in Python), each multiband raster input will be processed as a multiband raster.

    The number of bands in the output depends on the Input position raster. If the Input position raster is a single band, the number of bands on the output raster will be the same as the maximum number of bands of all multiband rasters from the Input rasters or constant values. If the Input position raster is a multiband, the output raster will have the same number of bands as the Input position raster.

    If any of the Input rasters or constant values is a raster with a smaller number of bands than the output raster, the missing bands will be interpreted as a band filled with NoData. If the cell value of the Input position raster picks value one from the missing band, the output raster will receive NoData. If any of the Input rasters or constant values is a constant, it will be interpreted as a multiband raster, in which the cell values of all bands are the same as the constant and have the same number of bands as the output raster.

Parameters

LabelExplanationData Type
Input position raster

The 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
Input rasters or constant values

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 will be processed.

  • Unchecked—Each band from a multiband raster input will be processed separately as a single band raster. This is the default.
  • Checked—Each multiband raster input will be processed as a multiband raster. The operation will be performed for each band from one input using the corresponding band number from the other inputs.
Boolean

Return Value

LabelExplanationData Type
Output raster

The output raster.

Raster

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

The 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 will be processed.

  • SINGLE_BANDEach band from a multiband raster input will be processed separately as a single band raster. This is the default.
  • MULTI_BANDEach multiband raster input will be processed as a multiband raster. The operation will be performed for each band from one input using the corresponding band number from the other inputs.
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.ia import *
env.workspace = "C:/data"
outPick = Pick("cost", ["degs", "negs", "fourgrd"])
outPick.save("C:/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.ia import *

# Set environment settings
env.workspace = "C:/iapyexamples/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("ImageAnalyst")

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

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

Related topics