nextgis / qgis_molusce

Modules for Land Use Change Simulations
https://github.com/nextgis/molusce
GNU General Public License v2.0
43 stars 15 forks source link

Error in getCrossTable #29

Closed inessante closed 3 days ago

inessante commented 5 years ago

I get this error when I try to obtain the Area Changes: File "C:/Users/usuario/.qgis2/python/plugins\molusce\algorithms\models\crosstabs\model.py", line 86, in getCrosstable if self._T == None: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() Could you help me? Thank you

Ines

vanthinh1711 commented 2 years ago

Hi there, I got the same error when trying to run the source code of MOLUSCE on python 3.xx. In my experience, MOLUSCE was build in an old version of python (maybe 2.7x). The expression "self._T == None" will confuse the new python 3.xx. If you run the source code of MOLUSCE, you can change "self._T == None" to "self._T is None". I sucessfully run MOLUSCE using its source code. However, I need to change some parameters in the source code. Hope this explanation is still useful. Regards,

avatar-007 commented 2 years ago

Thank you, effective way

felxcon commented 2 years ago

@vanthinh1711 thanks for your answer post, because I encounter the same issue as inessante! I tried but I couldnt find "self._T == None" in any of the plugin folder's content (where do I have to look, which python-file is it in?^^), and I didn't quite get what you mean with running "MOLUSCE using its source code" (I am using QGIS 2.18.18, I had Python3.9 already, and tried to have it easily solved by installing python2.7, but the issue remained.) I would be glad for help :)

vanthinh1711 commented 2 years ago

Hi @felxcon, thanks for your interest in my answer. I download the source code of MOLUSCE from: https://github.com/nextgis/molusce Last year, I tried to install MOLUSCE as a plugin in QGIS. But I encountered many errors during running the plugin. I gave up using MOLUSCE in QGIS. Therefore, I tried to understand the source code of MOLUSCE by understanding the file in: molusce/algorithms/tests/workflow.py. I also made some changes to the source code of MOLUSCE. As @inessante got an error File "C:/Users/usuario/.qgis2/python/plugins\molusce\algorithms\models\crosstabs\model.py", line 86, in getCrosstable, if self._T == None. If you have the same error as @inessante, please try to change "self._T == None" to "self._T is None" (in "line 86" of the file "model.py" in the path "../.qgis2/python/plugins\molusce\algorithms\models\crosstabs\model.py"). Please check your computer environment, the path to "model.py" can be different from @inessante. If this can not fix your issue. I suggest you purge remove Python3.9, Qgis2.18.18. Then, install Qgis again. Please do not install python3.x. Recently, I also can run MOLUSCE as a plugin in QGIS. My Computer Operating System is Ubuntu (14.04 LTS) and I installed Qgis 2.18.16. Because MOLUSCE had been developed 10 years ago. Its source code is based on the old version of python 2.7, PyQt4. Our computer is mostly using python3.xx, PyQt5. Therefore, many errors can happen during running MOLUSCE. I hope there will be a new version of MOLUSCE for QGIS3.xx. If you can not solve your problem, I am very happy to have a discussion on Zoom chat. My email: vanthinh1711@gmail.com please email me. Actually, I have not fully understood the source code of MOLUSCE, but if you want to run its source code, I think I can help you. Regards,

felxcon commented 2 years ago

Dear @vanthinh1711 ! thank you soooo muhc for the explanation, it worked "miracles" ;)! -> I went to *molusce\algorithms\models\crosstabs\model.py -> and changed the "self._T == None" to "self._T is None" (line 86). FYI: I found that the Pearson Correlation is calculated much faster than Cramer as well as Joint Information Uncertainty. All the best, Felix

vanthinh1711 commented 2 years ago

That is great. Enjoy your studying.

simgislab commented 3 days ago

Try brand new MOLUSCE 4 for QGIS 3 and let us know if the problem persists. Reopen if necessary.