[GIS] How to list items in a raster catalog

arcgis-desktoparcpypythonraster-catalog

I have a managed raster catalog in a file geodatabase that is comprised of 12 images. The screenshot shows the raster catalog footprint with the names of the tiff images that make up the raster catalog. How can I programmatically list the names of the items in a raster catalog? For example

["tiles_1000_overlap_1_1.tif", "tiles_1000_overlap_1_2.tif"...]

The following approach seems to access the items, although does not list the names. Similarly, using the arcpy.ListRasters() method returns an empty list.

import arcpy

arcpy.env.workspace = r'C:\temp\myFGDB.gdb\rascat'

rasters = arcpy.ListDatasets()

>>> rasters
[u'rascat\\Raster.OBJECTID = 1',
 u'rascat\\Raster.OBJECTID = 2',
 u'rascat\\Raster.OBJECTID = 3',
 u'rascat\\Raster.OBJECTID = 4',
 ....]

enter image description here

Best Answer

Provided that you have created a raster catalog with all the default settings, you should have the Name column in the raster catalog attribute table.

You can see the name of each raster dataset that is loaded into the raster catalog in ArcMap. Since you want to access the raster catalog properties programmatically, you cannot do that with the arcpy.Describe because the only thing you will get is the raster field name.

desc = arcpy.Describe("C:/data/simon.gdb/idaho")
print "Raster field name: " + desc.rasterFieldName

You cannot use the Export Raster Catalog Paths GP tool which creates a table listing the paths to the raster datasets contained in an unmanaged raster catalog or a mosaic dataset. This is because your raster catalog is managed.

What you can do though is to use the arcpy.da.SearchCursor to iterate the rows within your raster catalog just like you would do for a feature class or a table.

rasterCatalog = r"C:\Program Files (x86)\ArcGIS\ArcTutor\Raster\Data\Amberg_tif\RasterGdb.gdb\TempRasterCatalogManaged"
    with arcpy.da.SearchCursor(rasterCatalog,"*") as cur:
        for row in cur:
            print row
            print ""

(10, (4490522.500091553, 5478715.731109619), C:\Program Files (x86)\ArcGIS\ArcTutor\Raster\Data\Amberg_tif\RasterGdb.gdb\TempRasterCatalogManaged\Raster.OBJECTID = 10, u'110209.tif', 3860.400146484375, 931418.0806860365)

There you can see the file name u'110209.tif'.

Another approach is to use the Table To Table GP tool to export your raster catalog into a geodatabase table which will have all the attributes you can see when opening the attribute table for the raster catalog in ArcMap.

I understand that you might have certain use cases, but the raster catalog has been superceded by the mosaic dataset, which has many more capabilities, uses, and functions. Therefore, it is recommended that you manage raster data using a mosaic dataset instead of using a raster catalog.

Related Question