I am a beginner to python coding in GIS. I want to calculate the total number of counts in raster attribute table. In order to do that:
- I would like to build a attribute table of raster data
- use a loop through attribute table using ARCPY.SearchCursor()
Therefore, I wrote a code to build an attribute table. However, I am getting an error while running the code and not able to figure out the error in the code.
Code:
import arcpy
# Create the geoprocessing object
import arcgisscripting
gp = arcgisscripting.create()
#To overwrite output
arcpy.env.overwriteOutput = True
#Set environment settings
gp.workspace = "C:/Subhasis/Test/raster-read"
#Build Raster Attribute Table
gp.BuildRasterAttributeTable_management("sti-9", "Overwrite")
Error Message:
Traceback (most recent call last):
File "C:/Subhasis/Test/raster-read/test.py", line 15, in <module>
gp.BuildRasterAttributeTable_management("sti-9", "Overwrite")
ExecuteError: ERROR 000049: Failed to build attribute table
Failed to execute (BuildRasterAttributeTable).