Combine (Spatial Analyst)
Summary
Combines multiple rasters so that a unique output value is assigned to each unique combination of input values.
Illustration
Usage
-
Combine 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.
-
Combine 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 65536 unique values.
You can increase this number by changing a setting in ArcGIS. On the Main menu, select Customize > ArcMap Options. In the ArcMap Options dialog box, click on the Raster tab and modify the Maximum number of unique values to render field to an appropriate value.
Syntax
Parameter | Explanation | Data Type |
in_rasters [in_raster,...] |
The list of input rasters to be combined. | Raster Layer |
Return Value
Name | Explanation | Data Type |
out_raster |
The output combined raster. A unique integer value is assigned to each unique combination of input values. | Raster |
Code Sample
This example takes several input rasters in different formats (GRID, IMG, and TIFF) and outputs the unique combination values as an ESRI 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")
This example takes several input rasters in different formats (GRID, IMG, and TIFF) and outputs the unique combination values as an ESRI 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 # Author: ESRI # 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" # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Execute Combine outCombine = Combine([inRaster01,inRaster02,inRaster03,inRaster04]) # Save the output outCombine.save("C:/sapyexamples/output/outcombine")