danioxoli / HotSpotAnalysis_Plugin

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

Error occurs when launching the tool #84

Open raluds opened 2 years ago

raluds commented 2 years ago

Hi Daniele,

Thanks for developing & maintaining this very useful plugin. Installed it successfully on QGIS 3.22 - Ubuntu 20.04.

However, the error below occurs when I launch the tool (v 2.0.0 from https://plugins.qgis.org/plugins/HotspotAnalysis).

TypeError: cannot unpack non-iterable NoneType object Traceback (most recent call last): File "/home/domi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 547, in run layers, layers_shp = self.loadLayerList() TypeError: cannot unpack non-iterable NoneType object

When having some look at the code, the error seems normal. The reason is that the line 524 under the function "def loadLayerList() <--> hotspot_analysis.py" return NoneType object.

So returning a tuple of 2 empty lists (line 524) maybe an option. When adopting this simple solution among others, it may also be a good idea to add a condition under the function "def run()" before the line 548 "if len(layers) == 0". For example: "if len(layers_shp) == 0:" => display a message indicating that no ShapeFile layer was found in the layer panel.

That's only some idea but I'm sure you'll find better solution.

Note: To reproduce it, remove any ShapeFile layer from the layer panel; then launch the tool.

Best,

Ludo

danioxoli commented 2 years ago

Hi Ludo,

please have a look here: https://github.com/danioxoli/HotSpotAnalysis_Plugin/issues/36

Please be sure that: 0) at least 1 layer is in the layer panel 1) The 1st layer in the layer panel ,when starting the plugin, is a shapefile of points or polygons 2) The shapefile is projected (in a metric CRS) 3) The shapefile has at least a numeric field in the attribute table (no virtual fields from join operations)

You may try with one of the sample layer provided within this repo.

Hope this will solve your issue.

Best Daniele

raluds commented 2 years ago

Hi Daniele,

Thanks for your answer. Of course the tool works perfectly if there is already at least a point/polygon shapefile in the layer panel. :)

I only wanted to say that it may be a good idea (in terms of user experience) to display a message indicating that no shapefile was found in the layer player if that is the case. The reason is that sometimes the user forgot to add a shapefile before launching the tool. And then he/she encounters this error.

Best Ludo