How do you get individual rasters from within a raster catalog in Python?
I'm trying to:
Get each raster in a raster catalog
See if they are single band integer
If they are then calculate the raster attribute table
The raster catalog is stored in a SQL Server database and I need to automate building of raster attribute tables so that all users can then use the 'Classify' raster dataset renderer in ArcMap. They can't use this at the moment as they do not have 'CREATE TABLE' permissions in SQL Server and I really don't want to give them that permission.
So far I have:
import arcpy
arcpy.env.workspace = r"Database Connections\\RASTER.sde"
arcpy.MakeRasterCatalogLayer_management("catalogName", "temp")
rows = arcpy.SearchCursor("temp")
for row in rows:
raster = arcpy.Raster(row.Raster)
It bombs out at the 'arcpy.Raster' creation with 'TypeError: expected a raster or layer name'
I would recommend using a Mosaic Dataset rather than a raster catalog. A Mosaic Dataset will save you an enormous amount of disk space, and it performs much faster. Also, users will be able to change the symbology to Classified regardless if the source imagery has an attribute table or not.
Make sure you calculated statistics on your Mosaic Dataset. You can do this by right-clicking on your Mosaic Dataset in the catalog window > Calculate Statistics. You will then have the option to render the imagery with the 'Classified' option.