danioxoli / HotSpotAnalysis_Plugin

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

Error when opening HotSpot Analysis - 'min_threshold_dist_from_shapefile' #57

Closed Arcangale closed 4 years ago

Arcangale commented 4 years ago

Hello! I have installed Pysal following the tutorial, and when I open Hotspot Analysis on QGIS, an error pops up:

2020-09-10T12:23:33 WARNING Traceback (most recent call last): File "C:/[...]\hotspot_analysis.py", line 551, in run self.load_comboBox() File "C:/[...]\hotspot_analysis.py", line 472, in load_comboBox thresh = pysal.min_threshold_dist_from_shapefile(path) AttributeError: module 'pysal' has no attribute 'min_threshold_dist_from_shapefile'

I am using Windows 10, Pysal 1.14.3, QGis 3.10.1-A Coruña (and it runs Pysal 2.0.0) If you need any extra information, I'll be happy to give it.

Thank you for your help!

danioxoli commented 4 years ago

Hello,

which is the actual version of pysal? As from your message you mentioned 2 different...

If pysal 2 is installed you should try to remove this version and install pysal 1.14 or (suggested) uninstall the plugin that you installed from the official QGIS plugin repo and try to install (via .zip file) the experimental plugin version supporting pysal 2 that you can find here: https://github.com/danioxoli/HotSpotAnalysis_Plugin/tree/qgis3pysal2

Before trying the above, be sure that the layer you want to input to the plugin is a valid projected shapefile (point or polygon with at least 1 numeric attribute with no missing data) and place it at the top of the layer panel.

Best,

Daniele

Arcangale commented 4 years ago

Hello,

I have installed version 1.14.3, as following the instructions. And then I checked the version, using python -m pip show pysal and it showed 1.14.3.

Then I checked which version my QGIS uses (following a comment you posted about another problem), by running

import pysal
print (pysal.__version__)

and it showed version 2.0.0 Using the experimental plugin seems to work!

Kind regards, Marcelo

Arcangale commented 4 years ago

Hello,

I left it running overnight and when I came back in the morning it gave me an error. So I tried installing pysal 2.0.0 (following the instructions here) and tried again, but it gave me the same error.

Traceback (most recent call last): File "C:/[...]\HotSpotAnalysis_Plugin-qgis3pysal2\hotspot_analysis.py", line 623, in run y, threshold1) File "C:/[...]\HotSpotAnalysis_Plugin-qgis3pysal2\hotspot_analysis.py", line 347, in write_file outFeature.SetField(outLayerDefn.GetFieldDefn(j).GetNameRef(), inFeature.GetField(j)) File "C:\OSGEO4~1\apps\Python37\lib\site-packages\osgeo\ogr.py", line 4458, in SetField return _ogr.Feature_SetFieldString(self, fld_index, args[1]) RuntimeError: not a string

Do I need to change the numerical field to string? At the moment it is an integer field, with values ranging 0-6.

My layer is on top of all others, and I double checked that the binary field I want has no blank cells.

Also, is there any indication (like a loading bar) that the plugin is running? I'm just clicking ok and then waiting until QGis stops being unresponsive.

Is it best for me to downgrade QGIS to one that uses pysal 1.14.3?

Best regards, Marcelo

danioxoli commented 4 years ago

Hello,

About downgrading QGIS, there is no need of doing so as no version of QGIS comes with pysal installed. Unfortunately, this is something not connected to the plugin but to the QGIS software itself.

About the error, this looks merely an issue with the output layer saving. Are you sure that the original attribute filed has been formatted as Int? If you share the data I might try to see if the problem stays in your input file or is due to some unknown code error.

Best,

Daniele

Arcangale commented 4 years ago

Hello,

I am sorry for the delay, I spent most of yesterday trying to run an analysis to see if it came out different. I am sure the field is formatted in integer, but unfortunately I can't share the data, because it is sensible data and I'm legally binded to not share any type of data outside the project team. I can tell however that it is a big set of data (28 thousand points) and the field I'm trying to run the analysis is mostly composed of '0', and a few numbers ranging between '1' and '6'.

Thank you for your help, but my computer isn't dealing well with the amount of data I need to process, so I'm going to try other alternatives.

Cheers, Marcelo

danioxoli commented 4 years ago

Yes, the dimension of the dataset perhaps is too large for QGIS environment. You would obtain better performance using directly PySAL from Python or I would like to suggest to have a look to https://geodacenter.github.io (you can find here all the functionalities of the plugin and furthermore, with optimization for large datasets. Only output manipulation it's a bit limited with respect to QGIS but it might fit your case)

Please, just consider investigating other statistics rather than LISA as because it looks like your variable is not exactly a continuous numerical one but it is more similar to a categorical one (to which traditional LISA has no application)

Best, Daniele