AnsweredAssumed Answered

arcpy points in polygon check

Question asked by jderekito on Feb 26, 2013
Latest reply on Aug 27, 2014 by cnetto
Hello,
I have a list of points and a list of polygons both in a separate shape files.  I am trying to write a ArcPy script to loop through the points, and then the polygons respectively and tell me when a point is within a polygon.  I have tried both the contains and touches methods on polygons but haven't had any luck.  Any help would be appreciated. So far I have the following:

import arcpy  pointFeatureClass = "C:\\Data\\POINTS2.dbf" pointFieldList = arcpy.ListFields(pointFeatureClass) for field in pointFieldList:  curField = field.name   arcpy.AddMessage(curField)  ptRows = arcpy.SearchCursor("C:\\Data\\POINTS2.dbf", "", "", "CID;Shape","CID;Shape")  for ptRow in ptRows:   #Now loop through poly's testing for intersect  shpRows = arcpy.SearchCursor("C:\\Data\\counties.shp", "", "", "NAME;Shape","NAME;Shape")  for shpRow in shpRows:    #arcpy.AddMessage("Checking for point "+ str(ptRow.CID) +" in: " + shpRow.NAME)   if shpRow.Shape.touches(ptRow.Shape):    arcpy.AddMessage("Got it: " + shpRow.NAME)

Outcomes