danioxoli / HotSpotAnalysis_Plugin

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

Illegal Field Requested in GetField() #66

Open NateTillern opened 3 years ago

NateTillern commented 3 years ago

I have recently begun working with a new dataset. However, it is using the same shapefile that I have used previously with this plug-in to great success. The shapefile is of German NUTS3 regions (401 polygons) and the data that I'd like to apply the cluster analysis to is all integer values. One of the variables contains negative integers, however, this error occurs for all of the variables I attempt to use and so do not think that is the issue.

I've looked into the the code around the line errors the traceback mentions, but honestly am lost as to what they are accomplishing and cannot really do any debugging myself there unfortunately.

I have reinstalled both Pysal and the Plugin from scratch, to no noticeable difference.

Any help solving this error would be greatly appreciated. I was previously able to use this plugin successfully, however, that was about 6 months ago now, but I can provide more details about the new data if necessary for help solving the problem. Please let me know any other details I can provide to help with debugging.

Thank you for your time!

KeyError: 'Illegal field requested in GetField()' Traceback (most recent call last): File "C:/Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 572, in run u.append(geometry.GetField(C)) File "D:\Program Files\apps\Python37\lib\site-packages\osgeo\ogr.py", line 4399, in GetField raise KeyError("Illegal field requested in GetField()") KeyError: 'Illegal field requested in GetField()'

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] QGIS version: 3.10.2-A Coruña A Coruña, d4cd3cfe5a

NateTillern commented 3 years ago

So I realized that there was a new version of Qgis, and now I'm getting an error when I try to install the plug-in. I re-did the OsGeo Pysal steps and checking that row 95 in innit.py was commented out, but am still getting the error upon trying to install.

I did notice the Python versions don't seem to match up, in the error message it mentions Python39 while the innit.py file is nested in a Python37 folder. Seems like that's probably an issue? I'm using Qgis 3.16.8 Hannover now, should I go back to my previous version?

Thank you for your time and help!

Couldn't load plugin 'HotspotAnalysis' due to an error when calling its classFactory() method

ModuleNotFoundError: No module named 'pysal' Traceback (most recent call last): File "D:\Program Files/QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 334, in _startPlugin plugins[packageName] = package.classFactory(iface) File "C:\Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis__init__.py", line 34, in classFactory from .hotspot_analysis import HotspotAnalysis File "D:\Program Files/QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 793, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 38, in import pysal File "D:\Program Files/QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 793, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'pysal'

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] QGIS version: 3.16.8-Hannover Hannover, 8c50902e

Python Path: C:\Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ClusterPoints D:/Program Files/QGIS/apps/qgis-ltr/./python C:/Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins D:/Program Files/QGIS/apps/qgis-ltr/./python/plugins D:\Program Files\QGIS\bin\python39.zip D:\Program Files\QGIS\apps\Python39\DLLs D:\Program Files\QGIS\apps\Python39\lib D:\Program Files\QGIS\bin D:\Program Files\QGIS\apps\Python39 D:\Program Files\QGIS\apps\Python39\lib\site-packages D:\Program Files\QGIS\apps\Python39\lib\site-packages\win32 D:\Program Files\QGIS\apps\Python39\lib\site-packages\win32\lib D:\Program Files\QGIS\apps\Python39\lib\site-packages\Pythonwin C:/Users/clark/AppData/Roaming/QGIS/QGIS3\profiles\default/python

danioxoli commented 3 years ago

Sorry for the late reply.

Your previous issue was probably due to a join operation on the attribute table. The Plugin does not accept virtual fields as variables (see https://github.com/danioxoli/HotSpotAnalysis_Plugin/issues/17#issuecomment-435139066).

The second message instead is due to the new installation of QGIS that cannot actually access Pysal (probably in doing the new installation of dependencies the package was not placed correctly). I suggest switching to the Pysal 2 version of the plugin on Windows QGIS as reported here: https://github.com/danioxoli/HotSpotAnalysis_Plugin/tree/qgis3pysal2

Hope this will be useful