Skip To Content

Combine

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.

  • No more than 20 rasters can be used as input to Combine.

  • If a cell location contains NoData on any of the input rasters, that location will be assigned NoData on the output.

  • The output raster is always of integer type.

  • For formats other than Esri Grid, by default, the output raster from this tool can only have a maximum of 65,536 unique values.

    You can increase this number by changing a setting in ArcGIS Pro. On the Project tab, select Options and select the Raster and Imagery choice. In the dialog box, select the Raster Dataset choice and enter an appropriate value for the Maximum number of unique values to display.

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

Syntax

Combine (in_rasters)
ParameterExplanationData 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")

Licensing information

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

Related topics