Hi I am a beginner to python programming in GIS and am trying to calculate the area of a raster. When I ran the program, I got error message below. I am also providing my code. Any help would be greatly appreciated!
import arcpy
from arcpy import env
#To overwrite output
arcpy.env.overwriteOutput = True
#Set environment settings
env.workspace = "C:/Subhasis/Test/raster-read"
#set local variables-STI extraction
inRaster ="sti"
# Create a search cursor for raster attribute
read = arcpy.SearchCursor("inRaster","","","Value;Count","")
#read the counts in raster
for row in read:
count = row.getValue("Count")
print count
Error Message:
"Traceback (most recent call last):
File "C:/Subhasis/Test/raster-read/read-raster.py", line 14, in <module>
read = arcpy.SearchCursor("inRaster","","","Value;Count","")
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py", line 1167, in SearchCursor
return gp.searchCursor(dataset, where_clause, spatial_reference, fields, sort_fields)
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 359, in searchCursor
self._gp.SearchCursor(*gp_fixargs(args, True)))
IOError: "inRaster" does not exist"
inRaster
but you are passing it to your search cursor as a string"inRaster"
. Also, you should look into the data access module for an updated cursor object that's faster and more reliable. – Paul yesterday