Build Raster Attribute Table (Data Management)
Summary
Adds a raster attribute table to a raster dataset or updates an existing one.
Usage
-
If you want to delete an existing table and create a new one, check Overwrite. A new raster attribute table will be created, and the old one will be deleted.
-
If you have an existing table and you do not check Overwrite, the table will be updated. No fields will be deleted, but the values in the table will be up to date.
-
It is not possible to build a raster attribute table for a raster dataset that is a pixel type of 32-bit floating point.
Syntax
Parameter | Explanation | Data Type |
in_raster |
The input raster dataset. This must be a raster dataset with only a single band. It is not possible to build a raster attribute table for a raster dataset that has a pixel type of floating point or double precision. | Raster Layer |
overwrite (Optional) |
This allows you to overwrite any existing raster attribute table that might exist.
| Boolean |
Code Sample
This is a Python sample for BuildRasterAttributeTable.
import arcpy
arcpy.BuildRasterAttributeTable_management("c:/data/image.tif", "Overwrite")
This is a Python script sample for BuildRasterAttributeTable.
##====================================
##Build Raster Attribute Table
##Usage: BuildRasterAttributeTable_management in_raster {NONE | Overwrite}
try:
import arcpy
arcpy.env.workspace = r"C:/Workspace"
##Build attribute table for single band raster dataset
##Overwrite the existing attribute table file
arcpy.BuildRasterAttributeTable_management("image.tif", "Overwrite")
except:
print "Build Raster Attribute Table example failed."
print arcpy.GetMessages()