POST
|
I have a few questions about the suggested Python scripting for the Analyze Datasets tool. The suggested Python (from Analyze Datasets—Help | ArcGIS Desktop is: # Import system modules
import arcpy
import os
# set workspace
# the user in this workspace must be the owner of the data to analyze.
workspace = arcpy.GetParameterAsText(0)
# 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
# Get the user name for the workspace
userName = arcpy.Describe(workspace).connectionProperties.user.lower()
# remove any datasets that are not owned by the connected user.
userDataList = [ds for ds in dataList if ds.lower().find(".%s." % userName) > -1]
# Execute analyze datasets
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.AnalyzeDatasets_management(workspace, "NO_SYSTEM", dataList, "ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE")
print("Analyze Complete") Questions: Something I am unclear on and doesn't seem to be addressed in the documentation, should the Analyze Datasets tool should be run for BOTH the feature dataset AND feature classes and other datasets contained within a feature dataset, i.e. should line 16 in the script above be edited to include a list of feature datasets, such as in line 8 in the script below? On line 20 above an iteration through all the feature datasets begins. The workspace is set to the current feature dataset. A list of feature classes and datasets is then generated and added to the list. When the Analyze Datasets tool is run, my understanding is that 'Dataset names use paths relative to the input workspace; full paths are not accepted as input.' If that is the case, shouldn't the feature classes and datasets that reside within a feature dataset added have a relative path that includes the name of the feature dataset when added to the data list? If so, would the code need to be altered as below on lines 14-21? # 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() + arcpy.ListDatasets('', 'Feature')
# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them as a relative path to the master list
for dataset in arcpy.ListDatasets('','Feature'):
arcpy.env.workspace = os.path.join(workspace,dataset)
fc_list = arcpy.ListFeatureClasses()
for fc in fc_list:
fc_add = os.path.join(dataset, fc)
dataList.append(fc_add)
ds_list = arcpy.ListDatasets()
for ds in ds_list:
ds_add = os.path.join(dataset, ds)
dataList.append(ds_add)
# reset workspace... Thank you in advance for any clarification or suggestions!
... View more
09-13-2019
09:21 PM
|
1
|
0
|
785
|
POST
|
I am working on creating a python toolbox that uses a combine and then uses the combine VAT to join fields from other grid data. The scripting was built upon a previously existing tool that used the legacy coding for combine, arcpy.gp.Combine_sa. If using the legacy coding, the tool operates correctly, the combine is performed, and then several join fields are run, the joined raster is saved, and then new fields are added and calculated based on the join fields. However, if I replace the legacy combine coding with the current combine code and then save with combine.save(save_location) like this: I get the vexing error that the VAT_combine is not available. If I then build the attribute table, the combine field is there but the original value fields are not there (those fields are needed for the join field operation) The python toolbox is attached. The Combine coding begins at line 318. Thank you in advance for any suggestions or comments.
... View more
05-03-2019
10:01 AM
|
0
|
1
|
549
|
Title | Kudos | Posted |
---|---|---|
1 | 09-13-2019 09:21 PM |
Online Status |
Offline
|
Date Last Visited |
07-14-2021
04:44 PM
|