Geographic Information Systems Asked by Pangeleno on August 14, 2021
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:JungBrownfield=2020Parcels_poly_scag.gdb'
FC_list = arcpy.ListFeatureClasses()
#set workspace as gdb2 and get its list
arcpy.env.workspace = r'P:JungBrownfield=2020Superfund_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?
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()]
Correct answer by Anna Forrest on August 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP