Geoprocessing using feature classes from two separate geodatabases

2139
1
06-16-2014 12:53 PM
ToddHowell
New Contributor
Hello everyone,
      I seem to have hit a wall in my abilities once again. I have feature classes in two geodatabases. I am trying to iterate through the feature classes in the first geodatabase and based on the last 6 digits of the name find the matching feature class in the second geodatabase. Using the feature class from the first geodatabase in a for in loop and feature class in the second geodatabase that is located based on the last 6 digits of the feature class name, I would like to run the Locate Features Along Route tool using the first fc as the input and the second fc as the input route features. Is this possible? I'm not sure how to use ListFeatureClasses to list fc's in two separate geodatabases as it is environment dependent.

       Any help is greatly appreciated.


Todd Howell
Tags (2)
0 Kudos
1 Reply
OwenEarley
Occasional Contributor III
Hi Todd,

Try this method using a python list to store the input feature class names:


# Set you parameters (e.g. change to use tool inputs)
gdbInputs =  r"c:/temp/Inputs.gdb"
gdbRoutes =  r"c:/temp/Routes.gdb"

# Create inputs list
arcpy.env.workspace = gdbInputs
inputList = []
fcList1 = arcpy.ListFeatureClasses()

for fc in fcList1:
    inputList.append("{0}/{1}".format(gdbInputs,fc));

# Switch workspace (if required)
arcpy.env.workspace = gdbRoutes

for inputFC in inputList:
    # find your second feature class based on the last 6 digits
    targetFC = "{0}/Route{1}".format(gdbRoutes,inputFC[-6:])    
    # run your other processing with inputFC and targetFC
    print "Input FC: {0}".format(inputFC)
    print "Target FC: {0}".format(targetFC)



Owen
www.spatialxp.com.au
0 Kudos