Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Having trouble with selectbylocation

$
0
0
I'm unzipping a file, adding the shapefile contained within it to my map, and then trying to select by intersection with another layer.

The script runs fine but nothing gets selected.

Code:

import arcpy, zipfile, os.path

from arcpy import env

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

env.workspace = 'C:\Job\Frontline\Workspace'

TheZIP = arcpy.GetParameter(0)

TheP6 = arcpy.GetParameter(1)



zfile = zipfile.ZipFile(str(TheZIP))
zfile.extractall(r'C:\Job\Frontline\Workspace')

fc = arcpy.ListFeatureClasses ()
for f in fc:
    addLayer = arcpy.mapping.Layer(f)
    arcpy.mapping.AddLayer(df, addLayer)
    arcpy.MakeFeatureLayer_management(addLayer, "parcel_lyrr")
    arcpy.SelectLayerByLocation_management (addLayer, "INTERSECT", TheP6)

I've also tried for the final line:
Code:

arcpy.SelectLayerByLocation_management ("parcel_lyrr", "INTERSECT", TheP6)
But no luck.

Any help? Thanks!

Viewing all articles
Browse latest Browse all 2485

Trending Articles