hailst

ArcGIS 10 - LisctWorkspace / ListDataset - multiple types

Discussion created by hailst on Apr 25, 2014
Latest reply on Apr 28, 2014 by hailst
Hi,

Using PYTHON 2.6 & ArcGIS 10 - I'm writing a script in which I:

  1. Loop through all workspace under a given directory.

  2. Grab the details of all the Feature Classes, Rasters etc (both within and outside of Datasets).

  3. Populate a XLS with my results.


I'm finding that:

            workspaces = set(arcpy.ListWorkspaces('', 'FILEGDB'))-\
                         set(arcpy.ListWorkspaces('', 'COVERAGE'))


and

                rasters = set(arcpy.ListDatasets('','Raster'))-\
                          set(arcpy.ListDatasets('','Mosaic'))-\
                          set(arcpy.ListDatasets('','RasterCatalog'))
[

only provide access to the 1st type of Workspace/Dataset provided e.g. 'FILEGDB' and 'Raster'


        for root, dirs, files in os.walk(start_folder):
            folder_count += 1
            arcpy.env.workspace = root

            wspace = ""
            workspaces = set(arcpy.ListWorkspaces('', 'FILEGDB'))-\
                         set(arcpy.ListWorkspaces('', 'COVERAGE'))

            for wspace in workspaces:
                arcpy.env.workspace = os.path.join(root, wspace)

                # List out Raster Dataset & Raster Catalogs etc
                rasters = set(arcpy.ListDatasets('','Raster'))-\
                          set(arcpy.ListDatasets('','Mosaic'))-\
                          set(arcpy.ListDatasets('','RasterCatalog'))

                for rast in rasters:
                    inner_list_fcs = ['GDB Raster', wspace, "N/A", rast]
                    list_fcs += [inner_list_fcs]


If I do the following I get all the datasets specified:

                rasters = set(arcpy.ListDatasets('','Raster'))
                for rast in rasters:
                    inner_list_fcs = ['GDB Raster', wspace, "N/A", rast]
                    list_fcs += [inner_list_fcs]

                rasters = set(arcpy.ListDatasets('','RasterCatalog'))
                for rast in rasters:
                    inner_list_fcs = ['GDB Raster Catalog', wspace, "N/A", rast]
                    list_fcs += [inner_list_fcs]

                rasters = set(arcpy.ListDatasets('','Mosaic'))
                for rast in rasters:
                    inner_list_fcs = ['GDB Mosaic', wspace, "N/A", rast]
                    list_fcs += [inner_list_fcs]

Outcomes