0

I want to intersect one polygon file in a file geodatabase with multiple point files in a folder.

To access the file in the file geodtabase I do this:

arcpy.env.workspace=r'F:\Sheyenne\Sheyenne_lidar\for_histos\lidar.gdb'
shapes=arcpy.ListFeatureClasses()

when I do this:

for shape in shapes:
 print shape

my file is returned, named lidar_final_poly.

To access the files in the folder I want to intersect with I do this:

arcpy.env.workspace=r'C:\path_to_intersects'
intersects=arcpy.ListFeatureClasses(*.shp)

and then to intersect I do this:

for i in intersects:
 arcpy.Intersect_analysis([shapes,i]), outpath)

but this returns:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset F:\Sheyenne\Pixel_Regression\Viking\GDD_regress\NDII\shapefiles\NDII_ts.shp #;lidar_final_poly # does not exist or is not supported
Failed to execute (Intersect).
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 16, 2016 at 16:56

1 Answer 1

2

The paths to your files are changing when arcpy.env.workspace is changed, so when the script is run it can't find some of the files. e.g. print shape returns lidar_final_poly but it needs to return F:\Sheyenne\Sheyenne_lidar\for_histos\lidar.gdb\lidar_final_poly

import arcpy, os
gdbPath = r'F:\Sheyenne\Sheyenne_lidar\for_histos\lidar.gdb'
arcpy.env.workspace = gdbPath
shapes = arcpy.ListFeatureClasses()
shapeList = list()
for shape in shapes:
 print shape
 shapeList.append(os.path.join(gdbPath, shape)
shapePath = r'C:\path_to_intersects'
arcpy.env.workspace = shapePath
intersects = arcpy.ListFeatureClasses(*.shp)
for i in intersects:
 arcpy.Intersect_analysis([shapeList, i]), outpath)
answered Sep 16, 2016 at 19:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.