danioxoli / HotSpotAnalysis_Plugin

A QGIS plugin for hotspot analysis
GNU General Public License v3.0
56 stars 13 forks source link

MemoryError: std::bad_alloc #92

Open qianmeil opened 10 months ago

qianmeil commented 10 months ago

When I run the plugin using a few point for test,it works,but when I run this plugin with around 130000 latitude and longitude points,it report an error: Traceback (most recent call last): File "C:\Users/10784/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 610, in run w = DistanceBand(t, threshold1, p=2, binary=False) File "C:\Users\10784\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\distance.py", line 781, in init self._band() File "C:\Users\10784\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\distance.py", line 848, in _band self.dmat = self.kdtree.sparse_distance_matrix( File "D:\PROGRA~1\apps\Python39\lib\site-packages\scipy\spatial_kdtree.py", line 865, in sparse_distance_matrix return super().sparse_distance_matrix( File "_ckdtree.pyx", line 1528, in scipy.spatial._ckdtree.cKDTree.sparse_distance_matrix MemoryError: std::bad_alloc Windows 11 QGIS:3.34.2 python:3.9.5 Looking forward to your reply!

danioxoli commented 10 months ago

Hello,

It looks like you have a memory error in the computation of the spatial weights matrix (https://stackoverflow.com/questions/8378797/stdbad-alloc-am-i-using-too-much-memory). The Plugin is tested for some thousand points only... and 130k double-precision point coordinates may be too much for the plugin.

For such datasets, I suggest moving to Python directly.

Daniele

qianmeil commented 10 months ago

Hello,

Thank you for your quick reply! I have no idea how to run such a plugin on python directly,because there are many scripts and the plugin is related to QGIS,and I can not find out any useful information. I wonder if you can tell me detailed procedures or if you know any similar examples about running QGIS plugins on python directly.

Looking forward to your reply!

danioxoli commented 10 months ago

I suggest using directly PySAL (on which the Plugin is based). A relevant reference to start can be: https://geographicdata.science/book/notebooks/07_local_autocorrelation.html

Additionally, you may try other free software like GeoDa for computing LISA on your dataset. Have a look!

Best,

Daniele