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).
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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.