Build Raster Attribute Table (Data Management)

Summary

Adds a raster attribute table to a raster dataset or updates an existing one. This is used primarily with discrete data.

Usage

  • To delete an existing table and create a new one, check the Overwrite parameter. A new raster attribute table will be created, and the existing one will be deleted.

  • If you have an existing table and you do not check the Overwrite parameter, the table will be updated. No fields will be deleted, but the values in the table will be updated.

  • You cannot build a raster attribute table for a raster dataset that is a pixel type of 32-bit floating point.

  • You can generate an attribute table for a multidimensional dataset. When using this tool on a multidimensional mosaic dataset or a multidimensional raster, the output table will contain the pixel count of each class in each slice. The Count_S0 field will contain the pixel count of each class in the first slice of the dataset. The Count_S1 field will contain the pixel count of each class in the second slice, and so on. The variables must contain categorical data such as land cover.

Parameters

LabelExplanationData Type
Input Raster

The input raster dataset to which a table will be added. This tool will not run if the pixel type is floating point or double precision.

Raster Layer
Overwrite
(Optional)

Specifies whether the existing table will be overwritten.

  • NoneThe existing raster attribute table will not be overwritten and any edits will be appended to it. This is the default.
  • OverwriteThe existing raster attribute table will be overwritten and a new raster attribute table will be created.
Boolean
Convert colormap
(Optional)

Specifies whether the color map will be converted to a raster attribute table. The output raster attribute table will include Red, Green, and Blue fields containing color values from the color map. These fields define the display colors for the corresponding class values.

This parameter only applies when the Input Raster parameter value includes an associated color map.

  • Convert ColormapThe color map will be converted to a new raster attribute table.
  • NoneThe color map will not be converted to a raster attribute table. This is the default.
Boolean

Derived Output

LabelExplanationData Type
Updated Input Raster

The output raster dataset.

Raster Layer

arcpy.management.BuildRasterAttributeTable(in_raster, {overwrite}, {convert_colormap})
NameExplanationData Type
in_raster

The input raster dataset to which a table will be added. This tool will not run if the pixel type is floating point or double precision.

Raster Layer
overwrite
(Optional)

Specifies whether the existing table will be overwritten.

  • NONEThe existing raster attribute table will not be overwritten and any edits will be appended to it. This is the default.
  • OverwriteThe existing raster attribute table will be overwritten and a new raster attribute table will be created.
Boolean
convert_colormap
(Optional)

Specifies whether the color map will be converted to a raster attribute table. The output raster attribute table will include Red, Green, and Blue fields containing color values from the color map. These fields define the display colors for the corresponding class values.

This parameter only applies when the Input Raster parameter value includes an associated color map.

  • Checked—The color map will be converted to a new raster attribute table.
  • Unchecked—The color map will not be converted to a raster attribute table. This is the default.
  • ConvertColormapThe color map will be converted to a new raster attribute table.
  • NONEThe color map will not be converted to a raster attribute table. This is the default.
Boolean

Derived Output

NameExplanationData Type
out_raster

The output raster dataset.

Raster Layer

Code sample

BuildRasterAttributeTable example (Python window)

This is a Python sample for the BuildRasterAttributeTable function.

import arcpy
arcpy.BuildRasterAttributeTable_management("c:/data/image.tif", "Overwrite")
BuildRasterAttributeTable example 2 (stand-alone script)

This is a Python script sample for the BuildRasterAttributeTable function.

##====================================
##Build Raster Attribute Table
##Usage: BuildRasterAttributeTable_management in_raster {NONE | Overwrite}
    
import arcpy
arcpy.env.workspace = "C:/Workspace"

##Build attribute table for single band raster dataset
##Overwrite the existing attribute table file
arcpy.BuildRasterAttributeTable_management("image.tif", "Overwrite")

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics