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

Select features using geometry objects

$
0
0
Greetings,

I'm writing some arcpy to select polygons that contain the centroid of my current data frame extent. Here's my code:
Code:

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
myPt = arcpy.Point((df.extent.XMax+df.extent.XMin)/2, (df.extent.YMax+df.extent.YMin)/2)
myPtGeometry = arcpy.PointGeometry(myPt)

arcpy.SelectLayerByLocation_management ("DOQQImport", "COMPLETELY_CONTAINS", myPtGeometry)

The code runs without error, and the coordinates of myPt/myPtGeometry are correct. Yet, nothing gets selected.

Am I missing some coding step, or can you not use geometry this way?

Thanks,
Scott

Viewing all articles
Browse latest Browse all 2485

Trending Articles