1

I am working with a fairly large dataset and am trying to identify the points with a specific attribute (letter and number combination) that matches a polygon with the same attribute, but only when the point is spatially located within the matching polygon.

This may take more than one step and I have not been successful in search for the right steps.

2
  • 1
    Welcome to GIS SE. Thank you for taking the Tour. Please Edit the question to contain what you have attempted, and what error you encountered.
    – Vince
    Aug 18, 2018 at 15:51
  • Spatial Join polygon data to points then select by attributes where the columns match
    – BERA
    Aug 19, 2018 at 6:28

1 Answer 1

1

This Script will give list of all the eligible Points that have same attribute as spatially intesected Polygons. Further, you can pass this into definition query/select by attribute in point fc.

import arcpy

#Specify Deafult workspace for this script. it helps in - 1)all geoprocessing Output will created in this gdb. 2) you can specfiy fc with double quotes rathar than spcifying full path
arcpy.env.workspace = r"C:\Users\Sanjay\Documents\ArcGIS\SimilarPoints by attribute in polygon\mygdb.gdb"

#Set Output true to replace
arcpy.env.overwriteOutput = True

#best practise say to use makefeaturelayer rathan spcifying fc name.
arcpy.MakeFeatureLayer_management("Point","PointLayer")

#Lets do Spatial join get all intersected points with all attributes of pplygon attached
arcpy.SpatialJoin_analysis("PointLayer","polygon","SelectedPoints","JOIN_ONE_TO_ONE","KEEP_ALL")

# #best practise say to use makefeaturelayer rathan spcifying fc name.
arcpy.MakeFeatureLayer_management("SelectedPoints","SelectedPoints_lyr")

#where clause to be used where ID from points and poly will match  -ID for Poly fc, ID_Point is Point Fc
sql_exp = """ID_point = ID"""

#Select by Attribute from Spatial joined FC
arcpy.SelectLayerByAttribute_management("SelectedPoints_lyr", "NEW_SELECTION", sql_exp)



#Lets find out what are those points features has same attribute as polgon and falls into polygon
field = 'ID_point' #Specify field to extract list of id
values = [row[0] for row in arcpy.da.SearchCursor("SelectedPoints_lyr", field)]
uniqueValues = set(values)#Set to get Unique id which need
print "this are ids from point fc that has same attr. and spatially located in polygon"
for item in uniqueValues:

    print item

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.