Analyze Datasets

484
2
01-12-2012 10:47 AM
TedCronin
MVP Honored Contributor
Cool tool.  I can explicitly run analyze, but I only want to run from the dataset level, and the only option is to itemize every fc, so if I have 100 feature datasets with 20 feature classes in most of the fd, that is a lot of selecting, especially at the last minute that I don't want to analyze 1 specific FD with its 40 sub layers.  This change would need to be un selected manually.  Seems like I should have the capability to just analyze at the FD level, too.  Do like the idea though, at least 1 script will need to be reworked.
0 Kudos
2 Replies
RussellBrennan
Esri Contributor
Cool tool.  I can explicitly run analyze, but I only want to run from the dataset level, and the only option is to itemize every fc, so if I have 100 feature datasets with 20 feature classes in most of the fd, that is a lot of selecting, especially at the last minute that I don't want to analyze 1 specific FD with its 40 sub layers.  This change would need to be un selected manually.  Seems like I should have the capability to just analyze at the FD level, too.  Do like the idea though, at least 1 script will need to be reworked.


Ted,

The Analyze Datasets and Rebuild Indexes tools give you a list of all the data that the currently connected user owns. You are correct that we do not provide an option to just analyze a single feature dataset. If you are using the tool through the UI you will need to manually unselect the data that you do not wish to analyze. If you are running the tool through Python you could pass in a list of only the classes in the feature datasets you wish to analyze.

The help topic that I wrote for this has an example of how to get a list of all the data in your geodatabase. You could quickly alter this script to only use a single feature dataset as the source of the datasets to analyze.

Here is the current code sample:
# set the workspace environment
arcpy.env.workspace=workspace

# NOTE: Analyze Datasets can accept a Python list of datasets.

# Get a list of all the datasets the user has access to.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses() + arcpy.ListRasters()

# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets("","Feature"):
    arcpy.env.workspace = os.path.join(workspace,dataset)
    dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()

# reset the workspace arcpy.env.workspace = workspace



Change this to:
# set the workspace environment
arcpy.env.workspace=workspace

# The name of your feature dataset
FDS = 'NameOfYourFDS'

# NOTE: Analyze Datasets can accept a Python list of datasets.

# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets(FDS,"Feature"):
   arcpy.env.workspace = os.path.join(workspace,dataset)
   dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()

# reset the workspace arcpy.env.workspace = workspace
0 Kudos
TedCronin
MVP Honored Contributor
Thank you Russell.  I already have a py script to loop through feature datasets, so I would conceivably just use that one for awhile after 10.1 is formally released.  However, for people just getting started in managing gdbs these are both useful tools, in that they simplify workflows.  Its too bad the actual tool does have its limits, but as end users we are always going to get maximum flexibility with python.
0 Kudos