danioxoli / HotSpotAnalysis_Plugin

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

QGIS 3.4.10 Hotspot Analysis Plugin not installing #37

Open gariochquine opened 4 years ago

gariochquine commented 4 years ago

I'm hoping someone on here might be able to help me. I initially posted at gis.stackexchange.com and someone recommend raising an issue here. I'm fairly new to using QGIS and I'm completely lost. For my PhD project I have to use QGIS to produce georeferenced heatmaps based on informants' hand-drawn maps. An academic from another institution has provided me with step-by-step instructions of what to install and the steps to follow, but I've hit a big problem with installing the Hotspot Analysis plugin in QGIS.

I am working on a Macbook with QGIS 3.4.10. I've tried other installs of QGIS (2.18 and the new 3.8 release) but all presented the same problem. So far I have installed Python, as well as pip, numpy, scify, and pysal (as instructed). However, when I try to install the Hotspot Analysis plugin I keep getting this same error message:

Couldn't load plugin 'HotspotAnalysis' due to an error when calling its classFactory() method ModuleNotFoundError: No module named 'pysal.esda'

Does anyone have any idea how to rectify this? I've tried uninstalling and reinstalling everything. I've also tried installing the plugin from a zip file, but I still get the same message.

danioxoli commented 4 years ago

Dear,

thank you for your interest.

Troubles with installation are common due to the need for complex dependencies such as PySAL. Be sure to follow the instruction of the QGIS3 version of the plugin that you can find in the specific branch of the repo (here).

Your problem is due to the installed version of PySAL. The stable version of the Plugin uses PySAL version lower or equal than 1.14 while the from the PIP you get by default the latest version 2.0 (that causes the error due to big changes in the library APIs)

In the instruction at the above link, you can find a workaround to downgrade PySAL. Please, try the workaround and let me know if the problem is solved. I tested it on my Mac with QGIS 3.4 with success.

PS: In case your purpose is to produce heat maps only and not analyse the spatial association of your variables, the built-in Heatmap functionalities of QGIS may suit your need better.

Best,

Daniele

chapman09 commented 4 years ago

I have exactly the same problem as gariochquine! I followed the instructions for the mac installation provided in the README, successfully managed to install the pysal 1.14.3 but still after plugin installation I get the warning as mentioned above.

Is there anything I missed? Has someone that managed to run Hotspot Analysis on mac fixed the problem?

danioxoli commented 4 years ago

Dear chapman09,

the error indicates that you are actually installing pysal 1.14 on a Python distribution that is different from the one used by your QGIS3. In fact, the Module named 'pysal.esda' has change import pattern and name in version 2.0.

You can try to check the QGIS python version by typing

import sys
print(sys.version)

image

in the QGIS python console and be sure that you perform the pysal 1.14 installation in the right position.

Best,

Daniele

M5610020 commented 4 years ago

image

Facing above issue while installing the hotspot analysis plugin.

danioxoli commented 4 years ago

You may try open the init file "C:\User...\pysal__init__.py" and comment form line 43 to 48 preventing the import of Pandas. In the alternative, you may think to install the Pandas library in the same way you installed Pysal using pip install pandas (I suggest the first solution).

Best, Daniele

fca1970 commented 4 years ago

I only open the Hotspot menu and I get this problem: 020-06-20T01:11:07 WARNING Traceback (most recent call last): File "/home/paco/.local/share/QGIS/QGIS3/profiles/default/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 551, in run self.load_comboBox() File "/home/paco/.local/share/QGIS/QGIS3/profiles/default/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 472, in load_comboBoxthresh = pysal.min_threshold_dist_from_shapefile(path) File "/usr/lib/python3/dist-packages/pysal/weights/user.py", line 1079, in min_threshold_dist_from_shapefile points = get_points_array_from_shapefile(shapefile) File "/usr/lib/python3/dist-packages/pysal/weights/util.py", line 1095, in get_points_array_from_shapefile data = get_points_array(f) File "/usr/lib/python3/dist-packages/pysal/weights/util.py", line 1048, in get_points_array data = np.vstack([np.array(shape.centroid) for shape in iterable]) File "/usr/lib/python3/dist-packages/pysal/weights/util.py", line 1048, in data = np.vstack([np.array(shape.centroid) for shape in iterable]) File "/usr/lib/python3/dist-packages/pysal/core/FileIO.py", line 251, in nextr = self.read() File "/usr/lib/python3/dist-packages/pysal/core/FileIO.py", line 312, in readrow = self._read() File "/usr/lib/python3/dist-packages/pysal/core/IOHandlers/pyShpIO.py", line 142, in _readrec = self.dataObj.get_shape(self.pos) File "/usr/lib/python3/dist-packages/pysal/core/util/shapefile.py", line 362, in get_shape return self.shape.unpack(bufferIO(self.fileObj.read(byts))) File "/usr/lib/python3/dist-packages/pysal/core/util/shapefile.py", line 584, in unpackreturn _unpackDict(cls.USTRUCT, dat) File "/usr/lib/python3/dist-packages/pysal/core/util/shapefile.py", line 136, in _unpackDict fileObj.read(struct['size']))struct.error: unpack requires a buffer of 36 bytes

danioxoli commented 4 years ago

Please, try to open the plugin while having only a correct shapefile of points in the layer panel. This is a known behaviour that happens when e.g. the first layer in you project is a point text file or similar.

faalkao commented 3 years ago

Thank you for your very interesting tutorial. I tried and got the following problem. Could you help me out, please? An error has occurred while executing Python code:

ValueError: not enough values to unpack (expected 2, got 1) Traceback (most recent call last): File "/home/phan/.local/share/QGIS/QGIS3/profiles/default/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 564, in run (path, layer_id) = layerName.split('|') ValueError: not enough values to unpack (expected 2, got 1)

Python version: 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0] QGIS version: 3.16.1-Hannover Hannover, b381a90dca