I'm trying to get only raster catalog entries from a file geodatabase using the arcgisscripting geoprocessing API. So far I am able to do this using the ListDatasets function using the ALL argument. The problem is that it also returns raster datasets as well and I suspect there are other types it would return if they were present in the file geodatabase. I've tried the Raster argument but it returns the raster datasets and omits the raster catalogs. I guess I could filter the items returned from gp.ListDatasets("", "Raster") from the items returned from gp.ListDatasets("", "ALL") leaving me with what I'm looking for, however there might be some other type I don't know of that would be left in the list if it were present.

Here is the code I'm starting with:

import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.workspace = r"C:\FileGeodatabase"
datasets = gp.ListDatasets("", "ALL")
for dataset in dataset:
    #Only want raster catalogs here...

I'm looking for a way to get only raster catalogs. What approach would ensure I'm working only with raster catalogs?

| improve this question | | | | |

Try the RasterCatalog feature_type argument:

datasetList = arcpy.ListDatasets("C*", "RasterCatalog")

for dataset in datasetList:
    print dataset


OK, above won't work on 9.3, so what about getting the DatasetType of each object and if it is of type RasterCatalog, then list it (below code untested)?

datasets = gp.ListDatasets("", "ALL")
for dataset in datasets:
    desc = gp.Describe(dataset)
    if desc.DatasetType == "RasterCatalog":
        # do your thang

Here's a fancier workaround for 9.3 using a list comprehension:

cats = [c for c in gp.ListDatasets() 
        if gp.Describe(c).DatasetType == "RasterCatalog"]
| improve this answer | | | | |
  • Doesn't look like it's supported in 9.3 ERROR 999999: Error executing function.Workspace type is invalid. I think these are the types I'm limited to. – Andy Arismendi Jan 14 '12 at 1:08
  • @AndyArismendi - Sorry, looked only at the tags and saw arcpy, didn't notice the 9.3 gp in the code. Edited tags to reflect proper version of ArcGIS. See my edit about DatasetType – Chad Cooper Jan 14 '12 at 1:17
  • No problem, the arcgisscripting tag only has 2 followers where the arcpy tag has 31. I figured I might get some more eyeballs with the arcpy tag. Sorry for the confusion. – Andy Arismendi Jan 14 '12 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.