# Average Nearest Neighbor for X points instead of 1 point

Is there a tool similar to the Average Nearest Neighbor tool where instead of calculating the average for the closest point it calculates the average for the closest X points?

Yes, you should use the Generate Near Table tool. Your `in_feature` is the points feature you want to analyze. Your `near_feature` is the points feature close/surrounding the point to analyze. You must specify how far you want to limit the near table. As a result you will have a table with the distance values from the point you want to evaluate to the n points that you are interested. You can use any pivot table (excel works fine), or if you want more automated results you can use cursors to calculate the average distance. Hope this helps.

Uncheck the box `Find only closest feature (optional)` then enter the number of features to find in `Maximum number of closest matches (optional)`.

This will generate a table that has a `NEAR_RANK` attribute you can query to get the values you need.

• Does this tool work for the same feature class? It looks like it only works for two different feature classes. Commented Jun 2, 2016 at 19:42
• Never tryied for the same feature class. However, you can duplicate your fc and make one the in feature and the other one the 'near' one. Wil work great. Commented Jun 3, 2016 at 0:10
• @TuckerChapman... did it work? Commented Jun 3, 2016 at 15:50
• Yes it did. Thank you! I added a few images to your answer of what I did. Commented Jun 3, 2016 at 21:38

Sorry, but you are profoundly misunderstanding the tool/statistic. The nearest neighbor index (NNI) is a statistic for evaluating the spatial distribution of point observations, as to whether they are random or clustered.

This is one of the simplest indices in a family of statistics called Point Patten Analysis (PPA). The NNI tests the observed average neighbor distance against the expected and is not limited to a single neighbor, as you intimate. In fact, the average neighbor distance is calculated from a matrix of all pair-wise distances.

The Nearest Neighbor Index is calculated as:

Nearest Neighbor Distance (observed) `D(nn) = sum(min(Dij)/N)`

Mean Random Distance (expected) `D(e) = 0.5 SQRT(A/N)`

Nearest Neighbor Index `NNI = D(nn)/D(e)`

``````Where; D=matrix of neighbor distances, A=Area, N=number of observations`
``````
• I understand that but what I was wondering is if there is a tool that can calculate the "group-wise" distance for every point finding the minimal distance required for X points from a point and averaging that instead of 1 point and its closest neighbor (for each point). Commented Jun 2, 2016 at 17:57
• To what end? In this instance, the expected would be incorrect and yield an erroneous result. It sounds like you are describing the Ripley's-K statistic that calculates clustering a specified spatial (distance) lags. I believe that this statistic is available in ArcGIS under the spatial statistics toolbox "Multi-Distance Spatial Cluster Analysis " tool. Unfortunately, the commonly applied statistic, Besag's-L (standardizes the expected of K to zero, making it considerably more interpretable), is not available in ArcGIS and there is no simulation envelope to indicate statistical significance. Commented Jun 2, 2016 at 18:16
• I would also add that if your spatial process is inhomogeneous, as many are, then statistics based on kNN can be very misleading, particularly if spatial lags are introduced. Please delve into the primary literature, which is quite voluminous, on point pattern analysis and quantifying spatial process. There has been considerable progress, in spatial statistics, using intensity to normalize inhomogeneity and nonstationarity in spatial random fields. Commented Jun 2, 2016 at 18:23
• I am trying to calculate values for the search radius in the Empirical Bayesian Kriging tool. According to this post the Geostatistical Wizard sets it to search for at least 32 neighbors. I want to try different values and was wondering if there was a tool to calculate those distances for N neighbors instead of 1. Commented Jun 2, 2016 at 19:42