Martin-Jung / LecoS

LecoS QGis Plugin - Contains several analytical functions for land cover analysis
GNU General Public License v3.0
21 stars 19 forks source link

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #13

Closed sajeshksv closed 5 years ago

sajeshksv commented 5 years ago

Specifications: Ubuntu 18.04 QGIS: 2.18 LTS scipy: 1.0.1 PIL: 1.1.7 numpy: 1.15.2

I am getting the following error when I try running the Polygon Batch Overlay tool.

`Traceback (most recent call last): File "/home/sajesh/.qgis2/python/plugins/LecoS/lecos_dlg.py", line 872, in accept err, r = bat.go(cmd,cl,cellsize,None,rasE) File "/home/sajesh/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 151, in go array = self.getClipArray(poly) File "/home/sajesh/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 354, in getClipArray mask = self.imageToArray(rasterPoly) File "/home/sajesh/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 255, in imageToArray if a != None: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Python version: 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0] QGIS version: 2.18.26 Las Palmas, 83df334

Python Path: /usr/share/qgis/python/plugins/processing /home/sajesh/.qgis2/python/plugins/LecoS /usr/share/qgis/python /home/sajesh/.qgis2/python /home/sajesh/.qgis2/python/plugins /usr/share/qgis/python/plugins /usr/lib/python2.7 /usr/lib/python2.7/plat-x86_64-linux-gnu /usr/lib/python2.7/lib-tk /usr/lib/python2.7/lib-old /usr/lib/python2.7/lib-dynload /home/sajesh/.local/lib/python2.7/site-packages /usr/local/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages/gtk-2.0 /usr/lib/python2.7/dist-packages/wx-3.0-gtk3 /home/sajesh/.qgis2//python /home/sajesh/.qgis2/python/plugins/mmqgis/forms`

Is it something to do with my numpy/scipy/PIL versions?

Martin-Jung commented 5 years ago

Yes, looks like as if newer numpy versions deprecated some functionalities. I have no time to fix this now, but you could replace the line in File "/home/sajesh/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 255,

if` a != None:

with

if` a.any() != None:

and see if that helps

sajeshksv commented 5 years ago

Yes, looks like as if newer numpy versions deprecated some functionalities. I have no time to fix this now, but you could replace the line in File "/home/sajesh/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 255,

if` a != None:

with

if` a.any() != None:

and see if that helps

replacing with a.any() seems to have stopped throwing up the error, although now I am getting the following error

AttributeError: 'NoneType' object has no attribute 'GetFeatureCount'

sajeshksv commented 5 years ago

Yes, looks like as if newer numpy versions deprecated some functionalities. I have no time to fix this now, but you could replace the line in File "/home/sajesh/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 255,

if` a != None:

with

if` a.any() != None:

and see if that helps

replacing with a.any() seems to have stopped throwing up the error, although now I am getting the following error

AttributeError: 'NoneType' object has no attribute 'GetFeatureCount'

@Martin-Jung I got it to work! Seems there was some error in the data which was why the NoneType error was occurring. Thanks a lot!