soatley

Select features using geometry objects

Discussion created by soatley on Jun 7, 2013
Latest reply on Jul 3, 2013 by eulessdave
Greetings,

I'm writing some arcpy to select polygons that contain the centroid of my current data frame extent. Here's my 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

Outcomes