danioxoli / HotSpotAnalysis_Plugin

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

Failed to remove row #1

Closed rastermanden closed 6 years ago

rastermanden commented 6 years ago

When I run Local Getis-Ord Gi* with other settings like when checking "Use Knn standardized spatial weights" I get an error in Distance.py line 112 in "row.remove(i)". The error is caused by "i not in row array". error.zip

        neighbors = {}
        for i,row in enumerate(to_weight):
            row = row.tolist()
            row.remove(i) #This line (112) gives error 
            row = [ids[j] for j in row]
            focal = ids[i]
            neighbors[focal] = row
        W.__init__(self, neighbors, id_order=ids)

Any suggestions ?

danioxoli commented 6 years ago

Hi! I have tested your shapefile with the knn. Actually I have found that a bunch of points share the same position (somewhere offshore to Guinea: screen0

Actually, the Hotspot analysis does not deal with single location associated to multiple point geometries. Probably, the index is out of the array as it should store only pairwise positive distances computed between different locations (the Distance.py is an external command used by Scipy, I don't know much about it, you can try to dig into at: distance.py)

Removing these duplicated points the plugin works:

screen2

screen1

Let me know if the the issue is solved!

Daniele

rastermanden commented 6 years ago

It works for me also! Thank you very much.