Combine (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Combines multiple rasters so that a unique output value is assigned to each unique combination of input values.

Illustration

Combine illustration
OutRas = Combine([InRas1, InRas2])

Usage

  • The Combine tool works on integer values and their associated attribute tables. If the values on the input are floating point, they will be automatically truncated, tested for uniqueness with the other input, and sent to the output attribute table.

  • The Combine tool is similar to the Combinatorial Or tool. They both assign a new number to each unique combination of input values. However, in the Combine tool, you can specify a list of rasters, whereas in the Combinatorial Or tool, you can specify only two inputs, which can be rasters or constant values.

  • When a multiband raster is specified as one of the Input rasters parameter values (in_rasters in Python), all the bands will be used.

    To process a selection of bands from a multiband raster, first create a raster dataset composed of those particular bands using the Composite Bands tool; then use the result in the list in the Input rasters parameter (in_rasters in Python).

  • The output raster is always of integer type.

  • Each raster input is represented by a field in the output raster attribute table (RAT) in which the order of the fields in the output matches the order of the input rasters.

    If multiband inputs are present, the output identifies each band as an individual raster and the corresponding number of fields will be created.

    If the same raster is used multiple times, it will be considered as individual inputs; however, a warning will be returned.

  • The field name in the output RAT is based on the raster dataset name. If the field name is too long, it will be truncated to meet the field name length limitation. Any special character in the raster name that is not supported by the database will be replaced by an underscore.

    In the case of multiband inputs, the field name is constructed using two parts, separated by an underscore. The first part is derived from the name of the raster, followed by the index of the band, starting from 1.

    In the case of duplicate field names, each subsequent field name is made unique by modifying the raster name with an index starting from 1.

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

Parameters

LabelExplanationData Type
Input rasters

The list of input rasters to be combined.

Raster Layer

Return Value

LabelExplanationData Type
Output raster

The output combined raster.

A unique integer value is assigned to each unique combination of input values.

Raster

Combine(in_rasters)
NameExplanationData Type
in_rasters
[in_raster,...]

The list of input rasters to be combined.

Raster Layer

Return Value

NameExplanationData Type
out_raster

The output combined raster.

A unique integer value is assigned to each unique combination of input values.

Raster

Code sample

Combine example 1 (Python window)

This example takes several input rasters in different formats (Grid, IMG, and TIFF) and outputs the unique combination values as a Grid raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outCombine = Combine(["filter", "zone", "source.img", "dec.tif"])
outCombine.save("C:/sapyexamples/output/outcombine2")
Combine example 2 (stand-alone script)

This example takes several input rasters in different formats (Grid, IMG, and TIFF) and outputs the unique combination values as a Grid raster.

# Name: Combine_Ex_02.py
# Description: Combines multiple rasters such that a unique value is
#              assigned to each unique combination of input values
# 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
inRaster01 = "filter"
inRaster02 = "zone"
inRaster03 = "source.img"
inRaster04 = "dec.tif"

# Execute Combine
outCombine = Combine([inRaster01,inRaster02,inRaster03,inRaster04])

# Save the output 
outCombine.save("C:/sapyexamples/output/outcombine")