Created
September 17, 2014 20:47
-
-
Save amarinelli/14245c90834054738544 to your computer and use it in GitHub Desktop.
Sample 'Select by Location' using point geometry and query layer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
point = arcpy.Point(592326.779, 6241287.454) | |
ref = arcpy.SpatialReference(26708) #SRID | |
ptGeometry = arcpy.PointGeometry(point, ref) | |
conn = r'Database Connections\[email protected]' | |
layer = "polygon" | |
query = "select * from data_view_spatial2" | |
u_id = "leaseid (Text, Nullable)" | |
arcpy.MakeQueryLayer_management(conn, layer, query, u_id, "POLYGON") | |
arcpy.SelectLayerByLocation_management(layer, "CONTAINS",ptGeometry, "#", "NEW_SELECTION") | |
result = int(arcpy.GetCount_management("polygon").getOutput(0)) | |
print result | |
print "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment