Okay. My script is running but it is taking for ever! The percent bar on the bottom of ArcCatalog is still at 0%, hopefully this script ends up working. In the meantime I was hoping I could post it here and see if anyone can spot some errors. Basically I feel I am not that great at python scripting and I am sure I will get an error.
I have over 20 GDB in one folder. In each GDB there is a NB_featureclass, and a NHD_featureclass. Inside of each GDB I am wanting to run a Near on the NB and NHD feature class.
There is maybe 200 NB objects (points) and the NHD is a stream network. I simply want to know the distance to the nearest streamline from a NB object.
Thanks in Advance!
Code:
# Import arcpy module
import arcpy, sys, traceback
arcpy.env.overwriteOutput = True
from os import path as p
arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Work"
flds = ['DIST_TYPE', 'NWIFC_ODISTTYPE']
try:
for ws in arcpy.ListWorkspaces("*", "FileGDB"):
arcpy.env.workspace = ws
print '\n\nSearching in %s\n\n' %ws
NB = arcpy.ListFeatureClasses("NB*")
NHD = arcpy.ListFeatureClasses("NHD*")
for inputFC in NB:
arcpy.Near_analysis(inputFC, NHD)
print 'Near Distance Calculated For %s'%inputFC
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n%s\nError Info:\n%s\n" % (tbinfo, sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n%s\n" % arcpy.GetMessages(2)
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
print pymsg
print msgsI have over 20 GDB in one folder. In each GDB there is a NB_featureclass, and a NHD_featureclass. Inside of each GDB I am wanting to run a Near on the NB and NHD feature class.
There is maybe 200 NB objects (points) and the NHD is a stream network. I simply want to know the distance to the nearest streamline from a NB object.
Thanks in Advance!