ArcGIS Proximity – Conduct Conditional Near Analysis in ArcGIS Desktop

arcgis-desktoplatitude longitudeproximity

I have two shapefiles with different points (cities) in lat/lon, and I am running the Near Analysis tool to find the nearest point in the second shapefile for each point in the first one. However, I want to condition this such that both points in each dataset lie within the same polygon (e.g, an administrative region), or such that in the resulting near table I can at least see in which region each point is, along with the region of its corresponding nearest feature (so as to check if they match). I have a shapefile with the boundaries of all of said regions.

For instance: if I am looking at a point that happens to lie next to the boundary of the region it is in, the nearest point may be just outside of that boundary, in a different region. This is not useful for my purposes, as both points must lie within the same region

What would be the optimal strategy to proceed in this case? I am using ArcMap, and if necessary I can run ArcPy commands.

When I initially ran this without any sort of condition (e.g, simply using Near for points in the first .shp to the second one), while many points where correctly assigned a nearest point that lied in the same region (this was easy to check because their names were similar), many other points were matched to others in nearby (but not the same) regions, or even really far away regions (as there is far from perfect overlap in the coverage of each shapefile). This question, which I asked earlier, is related what I first did.

Please note that neither shapefile contains features that can be later compared after joining a generated NearTable, as suggested in the answer to this. To check, I would have to see in which region each of the initial points lie, and check whether each of the nearest ranked towns are in the same region or not. These regions' boundaries are in a separate shapefile. What I am asking is how to proceed with this.

Best Answer

This is what you originally managed to produce using Near tool:

enter image description here

It's enough to assign admin. regions id to setA and setB:

enter image description here

Transfer regions' ID to output of Generate Near Table, delete non-matching rows:

enter image description here

delete identical in near table using IN_FID and to get this:

enter image description here

This is essentially duplicate of 2nd post you are referring to and this is why I closed it.

Related Question