danioxoli / HotSpotAnalysis_Plugin

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

unpackDistruct.error: unpack requires a buffer of 20 bytes #89

Open dmatt100 opened 1 year ago

dmatt100 commented 1 year ago

Greetings!

I am excited to use this plugin however I continue having some issues. I have followed the plugin install instructions here: https://github.com/danioxoli/HotSpotAnalysis_Plugin/commit/0f8dfdd899a5ba5542f2e0c552ffce1d407785af

I am using QGIS 3.28.3 on Windows. The plugin seems to be installed correctly but when I go to click on the icon, I receive the Python Error: An error has occurred while executing Python code: See message log (Python error) for more details.

Below is the error that occurs (I've changed my username in the path directory information to 'user' for this post)...

2023-03-16T09:37:28 WARNING Traceback (most recent call last): File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\util.py", line 1028, in get_points_array data = np.vstack([np.array(shape.centroid) for shape in iterable]) File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\util.py", line 1028, in data = np.vstack([np.array(shape.centroid) for shape in iterable]) AttributeError: 'Point' object has no attribute 'centroid'

         During handling of the above exception, another exception occurred:

         Traceback (most recent call last):
          File "C:\Users/user/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3pysal2\hotspot_analysis.py", line 552, in run
          self.load_comboBox()
          File "C:\Users/user/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3pysal2\hotspot_analysis.py", line 473, in load_comboBox
          thresh = pysal.lib.weights.user.min_threshold_dist_from_shapefile(path)
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\user.py", line 86, in min_threshold_dist_from_shapefile
          points = get_points_array_from_shapefile(shapefile)
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\util.py", line 1077, in get_points_array_from_shapefile
          data = get_points_array(f)
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\util.py", line 1030, in get_points_array
          data = np.vstack([shape for shape in iterable])
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\util.py", line 1030, in 
          data = np.vstack([shape for shape in iterable])
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 254, in __next__
          r = self.__read()
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 315, in __read
          row = self._read()
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\iohandlers\pyShpIO.py", line 144, in _read
          rec = self.dataObj.get_shape(self.pos)
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 382, in get_shape
          return self.shape.unpack(io.BytesIO(self.fileObj.read(byts)))
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 631, in unpack
          return _unpackDict(cls.USTRUCT, dat)
          File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 135, in _unpackDict
          items = unpack(struct['order'] + struct['fmt'],
         struct.error: unpack requires a buffer of 20 bytes

Any assistance would highly appreciated. Thank you for creating this tool

Best, Matt

danioxoli commented 1 year ago

It sounds like an error on the analysis layer. Please, try to open a new QGIS project and follow test described in this comment: https://github.com/danioxoli/HotSpotAnalysis_Plugin/issues/84#issuecomment-1158046857

Let me know if the error persists.

Best

Daniele

dmatt100 commented 1 year ago

Hello Daniele,

Thank you for the quick reply. I will let you know how this goes.