3

I have two geodatabases with several feature classes in both of them. I want to spatial join the feature classes in gdb1 to those in gdb2. I tried to use "arcpy.ListFeatureClasses()" function, but it needs to set the workspace to one gdb to get its list. Here is what I wrote:

import os import pandas as pd import arcpy #set workspace as gdb1 and get its list arcpy.env.workspace = r'P:\Jung\Brownfield\=2020\Parcels_poly_scag.gdb' FC_list = arcpy.ListFeatureClasses() #set workspace as gdb2 and get its list arcpy.env.workspace = r'P:\Jung\Brownfield\=2020\Superfund_Brownfield_Database_2020.gdb' ds_list = arcpy.ListFeatureClasses() for i in ds_list: target_ft = i for j in FC_list: join_ft = j arcpy.SpatialJoin_analysis(target_ft, join_ft, target_ft + '_' + join_ft, 'JOIN_ONE_TO_ONE') 

And I got the error -

ERROR 000732: Target Features: Dataset SF_Active_Site_Inventory does not exist or is not supported.

It seems when I changed the workspace, the feature list of the former workspace expired.

How can I solve this problem?

0

1 Answer 1

3

As per @Vince's comment, you need to fully qualify the paths to your feature classes by prepending the appropriate path the to file geodatabase they come from.

For example, by using a list comprehension:

FC_list = [os.path.join(arcpy.env.workspace,fc) for fc in arcpy.ListFeatureClasses()] 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.