0

I am working in ArcGIS Desktop 10.5.1 (Basic level).

I have a point feature class and a polygon feature class. The point feature class has a field that contains either null or the ID of one of the polygon features. What's the easiest way to test whether each point is located inside the polygon it refers to and storing the result in an additional "inPolygon?" field on the point feature?

EDIT: I've got ~122k points and 33 polygons. Many of the polygons overlap. It's possible that a point could fall within all 33 polygons or within none of them, but each point references either none or exactly one polygon that I want to test for.

  • What feature type are your points and polygons? Are they geodatabase or shapefile? What's already in the table? Are you capable of writing python scripts or ArcObjects code? – Michael Stimson Feb 27 '18 at 22:43
  • Near on point s, does it. After it join polygons using their oid to near_fid and select ones that match. W basic use spatial join, closest, instead of near. – FelixIP Feb 28 '18 at 1:29
  • Both the points and polygons are geodatabase feature classes. There are 33 polygons and ~122k points. The polygons all overlap to some degree. Some of the points might fall in all 33 polygons, some might fall in none, but each point references one or zero polygons that it should fall into. – GenuineSmile29 Feb 28 '18 at 14:37
3

There are a number of ways you could do this, and the "easiest" way will vary depending on several factors, including the number of features in each feature class.

If it is a small number of polygons, you can iterate through the polygons, selecting the points that are within the polygon by a select by location query, and then do an attribute selection from the already selected features where the polygon's ID and the polygon ID in the points do/do-not match, and then calculate a value into the inPolygon field accordingly. This is not likely a good solution if you have more than a few polygons though.

Method 2 would be to ensure there is a unique ID field in the point feature class (this could even be calculating the ObjectID/FID into a new field). Then do a spatial join with the polygon's feature class to add the ID of the polygon the point falls within. This will create a new feature class. You will then do a table join of the original points feature class with this newly created feature class (spatial join output) based on that unique ID. Then do a select by attribute where the polygon ID from the original point does/doesn't match the polygon ID from the spatial join results. Finally, based on these selected features calculate the inPolygon field to have the desired value.

If I need to clarify, let me know.

  • Like your method 1 but I would script it in python. However if the points or polygons are shapefiles finding unmatched ID values is kind of pointless as the FIDs are fluid. – Michael Stimson Feb 27 '18 at 23:59
  • Going to try your second approach. Will report back. – GenuineSmile29 Feb 28 '18 at 14:45
  • @MichaelStimson Sorry if I wasn't clear, I agree FIDs are fluid, that's why in method 2 I suggest you calculate the FID/OID into a new field or use some other static unique ID field to do the joins on. And in both methods, the result should be a new inPolygon field populated with yes or no (or equivalent) in the original points feature class, not a list of FIDs. The FID was just mentioned as a good source for a unique ID field used to join based on. – John Feb 28 '18 at 14:45
  • This approach is not working because the spatial join only joins the FIRST polygon it finds that the point is within, not every polygon in the set that the point is within. Sorry for failing to mention this in my original specification, but many of my polygons overlap. – GenuineSmile29 Feb 28 '18 at 14:49
  • @GenuineSmile29 per your comment above, you mention you have overlapping polygons. Therefore, you may need to adjust method 2 slightly to fit your use case. One option would be to use the JOIN_ONE_TO_MANY option in the spatial join. That would create duplicate points where it intersected multiple polygons, but in the resulting FC you could just select and extract the point features where the new Polygon derived ID matches the existing polygon ID from the point attributes. Then attribute join that subset of feature back to original and calculate all joined as inPolygon True (all else False). – John Feb 28 '18 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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