Select to view content in your preferred language

How to Spatially Join All Points Nearest to Target: ArcGIS Pro

2568
3
12-18-2019 11:35 AM
ByronSchuldt
New Contributor

I am working with two layers, a point layer of crime locations and a point layer of police station locations:

For each police station, I would like to calculate the number of crime points that are closer to it than to any other station. For example, 30 crime locations occurred closest to police station X, while 50 occurred closest to station Y, etc. In ArcMap, there is an option within the spatial join dialogue box to give each target feature a summary of all points that are closest to it:

However, I don't see a similar option in ArcGIS Pro 2.4.1. I see an option to join the single closest feature to target features, but not all features that are closest to that station. Is there a way to do this in pro?

Thank you sincerely for any help you can provide,

Byron

0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Byron,

You can do this using the Spatial Join tool.  If you want to include all points for each Police Station, just specify the Match Option to Within a Distance and set the search radius to a large value that will include all points.  Ex:

0 Kudos
ByronSchuldt
New Contributor

Hi Jake,

Thanks for your reply. Perhaps my understanding is off, but wouldn't using 'Within a distance' be similar to joining all points falling within a fixed buffer from the police stations?

This may not be able to do what I want. For example, a crime may occur within 100 meters of 2 different police stations, so it would be joined to both. However, it's closer to police station X, and I only want to join it to the station it's closest to. If I change the distance to be smaller, I will inevitably be unable to join all crime points to stations.

NobbirAhmed
Esri Regular Contributor

I'm afraid a single tool can solve your question  unless someone comes up with a nice solution  

The simplest two-step process will be (conceptually):

1. to find closer crime points (pre-defined higher estimated number)  within a distance from police stations.

2. iterate over step 1 for each police station. For each police station, there will be many points that are within the distance specified but those points are closer to some other police station. We need to compare distances from police stations to filter out ones that are closer to one station than all other stations.

The (proposed) practical solution is:

Run Generate Near Table with police stations as Input Features and crime points as Near Features. 

Make sure you uncheck 'Find only closest feature'.

I'm afraid you won't know beforehand which values to put for Search Radius and Max number of closest features. You may need some trial and errors.

Now the output of this run will be a table that will show distances of crime spots from police stations with a RANK number - closest crime point will get 1, next one will get 2 and so on. With my dummy data the output of Generate Near Table looks like this:

See, the crime spots are ranked (from each police station) by distance. 

Next, you'll need to look at the NEAR_FID field - if a value appears more than once (eg 20 here) then the same point is being counted twice. You may need to write a Python script to weed out the duplicates.

The story is not over: once you know the crime points closest to each station you'll need to run Spatial Join to transfer the attributes    

Let's wait - someone else might come up with a simpler and delicate solution