I was able to get this working if I wrote the PointGeometry to a shapefile rather than an IN_MEMORY feature, or a feature class. Here's an example:import arcpy arcpy.env.overwriteOutput = 1 input = arcpy.GetParameterAsText(0) rows = arcpy.SearchCursor(input) for row in rows: geom = row.shape X = geom.centroid.X Y = geom.centroid.Y point = arcpy.Point(X, Y) ptGeometry = arcpy.PointGeometry(point) arcpy.CopyFeatures_management(ptGeometry, r"C:\temp\python\POINT.shp") arcpy.MakeFeatureLayer_management(r"C:\temp\python\POINT.shp", "point") mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] for layer in arcpy.mapping.ListLayers(mxd, '', df): if layer.name.lower() == "cities": arcpy.MakeFeatureLayer_management(layer, "cities_lyr") arcpy.SelectLayerByLocation_management("cities_lyr", "INTERSECT", "point", "30 FEET", "NEW_SELECTION") rows = arcpy.SearchCursor("cities_lyr") for row in rows: arcpy.AddMessage(row.NAME) print row.NAME del row, rows arcpy.Delete_management(r"C:\temp\python\POINT.shp")
You can add more 'if' statements for the other layers you would like to identify, and alter the 'arcpy.AddMessage' to display the info you would like to show. The info will be reported to the GP windows, or to the 'Results' window > Messages. I couldn't find a way to display the info to the Python window at 10.0, but this works using an add-in at 10.1.
Also, I believe since I used a shapefile the XY coordinates were slightly different when trying to identify a point feature class. I had to adjust the search distance to around 30 feet in the Select Layer by Location function to identify the correct point (city in the above example).
arcpy.CopyFeatures_management(ptGeometry, r"C:\temp\python\POINT.shp") arcpy.MakeFeatureLayer_management(r"C:\temp\python\POINT.shp", "point")
arcpy.CopyFeatures_management(ptGeometry, "IN_MEMORY/POINT") arcpy.MakeFeatureLayer_management("IN_MEMORY/POINT", "point")
logpath = r"C:\temp\python\file.txt" if os.path.exists(logpath): os.remove(logpath) f = open(logpath, "w") mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] for layer in arcpy.mapping.ListLayers(mxd, '', df): if layer.name.lower() == "cities": arcpy.MakeFeatureLayer_management(layer, "cities_lyr") arcpy.SelectLayerByLocation_management("cities_lyr", "INTERSECT", "point", "30 FEET", "NEW_SELECTION") rows = arcpy.SearchCursor("cities_lyr") for row in rows: f.write(row.NAME) del row, rows f.close()