I keep thinking that I must be missing something, but there does not seem to be a tool in ArcGIS 10 to select features (in particular polygons) from a layer at a point (X,Y) location via ArcPy. The parameters for such a tool would just be a layer name and an XY location.
At the moment I workaround this by creating a point featureclass containing the point and performing a SelectLayerByLocation on it. However, when the polygon feature class is in Oracle (accessed via ArcSDE 9.x) and contains 3.5 million polygons the time taken to make the selection can be more than 5 mins when I think a second or two (with less code) would be more appropriate. The feature class has a spatial index and I've tried using arcpy.env.extent (which SelectLayerByLocation appears to ignore) to restrict the geographic area accessed but the performance remains very poor.
Is there a quicker way to do this using ArcGIS Desktop 10 and ArcPy?
Thanks Jason Scheirer for some more concise code: SelectLayerByLocation(in_layer=arcpy.PointGeometry(arcpy.Point(x, y)), select_features="mylayer")
And especially to Chris Snyder for a performance tip: "A speedier work around might be to buffer your point a bit and then use the buffer extent as the analysis extent to make an in_memory copy (CopyFeatures tool) of your SDE data, and then do a SelectByLocation on the smaller and local in_memory dataset. That way you are sort of making the SelectByLocation tool honor the analysis extent environment, which it would not normally do. BTW: Any features that overlap with the analysis extent will be copied with the CopyFeatures tool.
I sure wish the SelectByLocation tool and the cursors methods honored the analysis extent... "
My own ideas were starting to go to trying to use Make Query Table with Spatial SQL (e.g. ST_Overlaps or ST_Intersects) but was unsure of the syntax. If anyone can provide an answer along those lines, or if Chris Snyder is able to just put an answer that can be a copy/paste of mine (from his help) then I am keen to tick the answer box.