geotechTools mapData (kdTree)
Introducing the Python geotechTools last week (and the repository on GitHub), the example did little more than robustly read and filter the data, plus a simple plot. In the article about using Python, not Excel, I previously introduced the kdTree library in scipy.spatial. This extraordinarily efficient and robust tool enables mapping of millions of points to their closest counterpart in another dataset in seconds. Sounds very useful?
By adding kdTree to the class xyzData() as a method to map data, very complex workflows can be shortened to a few lines of high-level Python.
mapData()
This method operates on either
extractArrayN4()
In case there is a need to extract a single column out of xyzData, this method becomes useful. It returns an np.array of shape (N, 4) compatible with the above. A nice example on how compact the code can become with numpy:
If you think this is cool, please do hit 'like' or leave a comment 😉
I've added a Jupyter notebook with this code (mapData_geotechTools.ipynb) to the GitHub repository as the main for the project, geotechTools.py, usually reflects the latest example - https://github.com/SMArndt/geotechTools/blob/main/mapData_geotechTools.ipynb
Thanks for sharing Stephan. I've been using the value transfer function within Gem4D for this task. Great to know of this method within Python. Thanks!