Iterate Rasters in a Raster Catalog

2948
3
08-31-2012 01:33 AM
AndrewCorcoran
New Contributor III
How do you get individual rasters from within a raster catalog in Python?

I'm trying to:


  1. Get each raster in a raster catalog

  2. See if they are single band integer

  3. 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'

Thanks in advance for any help.
Tags (2)
3 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Andrew,

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.
0 Kudos
AndrewCorcoran
New Contributor III
Thanks for the reply Jake.

I tried your suggestion but there is no 'Classify' renderer for mosaic datasets.

So I'm back to using a raster catalog - anyone been able to iterate through the raster datasets in a raster catalog using Python?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Andrew,

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.

[ATTACH=CONFIG]17454[/ATTACH]
0 Kudos