GispoCoding / eis_toolkit

Python library for mineral prospectivity mapping
https://eis-he.eu/
European Union Public License 1.2
26 stars 8 forks source link

Add optimized version of distance computation #455

Closed msorvoja closed 1 week ago

msorvoja commented 1 week ago

Adds an optimized version of distance computation using spatial indexing (scipy.spatial.cKDTree) for nearest neighbor search and Numba (njit decorator) for more efficient computation of distances. Old and new implementation are compared in notebooks/testing_distance_computation.ipynb.

nmaarnio commented 1 week ago

The final optimized version does not use cKDTree, only Numba.

Performance comparison of old and new version:

Geometries: Line dataset with 85 feature

Old version

New version

Geometries: Polygon dataset with 8 features

Old version

New version

Additional Distance to anomaly test:

msorvoja commented 1 week ago

@nmaarnio Tested with IOCG point, line and polygon data, and the results look good to me!

nmaarnio commented 1 week ago

There was a bug @Mtk112 noticed that occurred for some numpy and rasterio versions on Windows at least. It should be fixed now.

This PR should be ready to be merged now 🚀