0

ArcGIS Pro offers the Average Nearest Neighbour Distance geoprocessing tool to measure the distance between each feature centroid and its nearest neighbour's centroid location. It then averages all these nearest neighbour distances and provides a report of: Observed Mean Distance, Expected Mean Distance, Nearest Neighbour Index, z-score, and p-value

For more information on how the tool works see below: https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-statistics/h-how-average-nearest-neighbor-distance-spatial-st.htm

I'm curious as to whether any Python modules offer similar functionality? I'd like to be able to incorporate some kind of nearest neighbour analysis in future scripts - in particular, observed mean distance and expected mean distance.

3

2 Answers 2

0

You can try with networkx. First the data should be converted into networkx graph nodes and edges using python code. https://networkx.org/documentation/stable/tutorial.html Then use the inbuilt methods of networkx to find distance, nearest neighbour etc. https://networkx.org/documentation/networkx-1.9/reference/generated/networkx.algorithms.assortativity.k_nearest_neighbors.html

-1

Yes, there is a tool like this. Have a look at https://docs.qgis.org/3.22/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgisnearestneighbouranalysis

2
  • Thanks but I'd like a python way of doing it. In order to execute the above tool I'd have to run qgis.core and that is not ideal in my case Commented Apr 29, 2022 at 10:17
  • 1
    Then add this information (not being able to use qgis.core) to your question
    – Mazu_R
    Commented May 3, 2022 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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