nextgis / qgis_molusce

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

Error with calculate area changes in QGIS v2.6 #4

Closed simgislab closed 9 years ago

simgislab commented 9 years ago

I get the next error in calculate area changes with QGIS v2.6:

Ha ocurrido un error mientras se ejecutaba el código de Python:

Traceback (most recent call last): File "/home/samtux/.qgis2/python/plugins/molusce/moluscedialog.py", line 393, in >updateStatisticsTableDone self.drawTransitionStat() File "/home/samtux/.qgis2/python/plugins/molusce/moluscedialog.py", line 1007, in >drawTransitionStat stat = self.inputs["crosstab"].getTransitionStat() File "/home/samtux/.qgis2/python/plugins/molusce/algorithms/models/crosstabs/manager.py", line >91, in getTransitionStat deltas = finalArea - initArea ValueError: operands could not be broadcast together with shapes (3,) (4,)

simgislab commented 9 years ago

moved from https://hub.qgis.org/issues/11586

KolesovDmitry commented 9 years ago

We need more information for solve the issue.

The most probable cause is the difference in the initState and the finalState: seems that the initState has 3 classes but the finalState has 4 classes. But we need the input rasters to check it.

virginia13 commented 9 years ago

Hi all,

I got the same error when I click the bottom ‘updating the table’ in the tab ‘area changes’ (before to create the changes map). (The geometries were matched):

Traceback (most recent call last): File "C:/Users/PPP/.qgis2/python/plugins\molusce\moluscedialog.py", line 393, in updateStatisticsTableDone self.drawTransitionStat() File "C:/Users/PPP/.qgis2/python/plugins\molusce\moluscedialog.py", line 1007, in drawTransitionStat stat = self.inputs["crosstab"].getTransitionStat() File "C:/Users/PPP/.qgis2/python/plugins\molusce\algorithms\models\crosstabs\manager.py", line 91, in getTransitionStat deltas = finalArea - initArea ValueError: operands could not be broadcast together with shapes (5,) (6,)

Both files (input and output) were created with the plugin ‘interpolation’, introducing the same coordinates for the output file and the same cell size. I have tried different combinations of input-output rasters created as I described before (all with matched geometry), and with one of the combinations the table was created. Unfortunately this combination does not work for me. (I cannot find the difference between the characteristics of the files that work, and the ones that do not work...) Do you know how could I avoid the error? I can send you the rasters if you need them.

Once I got to create the table in the tab ‘area changes’, when trying to create the changes map, I got the following error:

Traceback (most recent call last): File "C:/Users/PPP/.qgis2/python/plugins\molusce\moluscedialog.py", line 416, in createChangeMap self.analyst = AreaAnalyst(self.inputs["initial"], self.inputs["final"]) File "C:/Users/PPP/.qgis2/python/plugins\molusce\algorithms\models\area_analysis\manager.py", line 62, in init raise AreaAnalizerError("List of categories of the first raster doesn't contains a category of the second raster!") AreaAnalizerError

I would be very thankful if you could help me to solve the issues

Best regards Virginia

KolesovDmitry commented 9 years ago

Hello, Virginia, I would be grateful if you provide an examle of your rasters. Could you please attach a pair of them (initial state and final state rasters)

virginia13 commented 9 years ago

Hello KolesovDmitry, When I try to upload them here, it says that it does not support the files, so I have sent them to your email address

simgislab commented 9 years ago

use dropbox and put links here after sharing

KolesovDmitry commented 9 years ago

I recieved the rasters

virginia13 commented 9 years ago

Ok, thank you very much both; this is the link of dropbox anyway

https://www.dropbox.com/sh/yg6j4mg4tn1527a/AACZqvKZcL2rFLAyZzD-rI29a?dl=0

KolesovDmitry commented 9 years ago

Hello, Virginia, I tested your rasters and find one amazing thing: the input/output rasters are float-point. Molusce was developed to handle integer rasters only (we can process discrete input values, but not continues). It is not a bug, it is the main idea of the molusce models:

So I have a couple of questions for you: what are your init/final rasters? Are they really continues?

virginia13 commented 9 years ago

Hi Dmitry,

(I do not know much about Gis, not much -or anything- about programming either, so I apoligize first if I do not use the appropriate words :).

Thank you very much for your fast and precise answer.

I did not know really how the program works. I tried for example to calculate the correlations, and with the Cramer's said that the data should be converted into categorical (because of the kind test), but when calculating the Pearson's correlations did not say anything, so I thought it worked also with float -points.

The rasters are calculated interpolating the results of a survey campaign related with the perception of the environment, and now they are not continuous: The answers of the questions were rated in a 7 points Likert's scale. (1=very bad, 4=neutral, 7=excellent). We made a vectorial layer of points, each point corresponding to the location of the interviewees. The attributes of the layer were the different questions, and physical parameters measured. And with this, the different rasters were created interpolating values. The initial raster represented the answers to one question of the first campaign developed (interpolated), the final raster could be the mean values of the answers of the first campaign made in an specific area (with similar features for our porposes), or the answers of the same question in second campaign to evaluate the changes.

I have been thinking on how to solve it. In our case it does not matter much the specific value asigned to a cell of the raster. (It has no sense so say that in an specific point the people would probably give a rating of 6.54). The objective of the maps are to give an idea of the opinion of people (positive-high, positive-low, and so on...), and the objective of using Molusce is to study the variables that can influence the responses, and represent the 'prediction' considering this variables ...

So, I could asign the same integer values (5.63 -->6, 4.32 -->4, and so on)to the cells. Or if I want more precision or nicer visual representation, I could multiply the values of the answers before interpolating by 10, 100...( 56, 43 would be possible values...or 563,432), and convert the raster into categorical data

Do you think that it could work? Could the use for example 700 different values make the calculation process longer than the use of 7?

Thanks again Virginia

-----Messaggio originale----- Da: Dmitry Kolesov [mailto:notifications@github.com] Inviato: ven 01/05/2015 7.50 A: nextgis/molusce Cc: Virginia PUYANA ROMERO Oggetto: Re: [molusce] Error with calculate area changes in QGIS v2.6 (#4)

Hello, Virginia, I tested your rasters and find one amazing thing: the input/output rasters are float-point. Molusce was developed to handle integer rasters only (we can process discrete input values, but not continues). It is not a bug, it is the main idea of the molusce models:

So I have a couple of questions for you: what are your init/final rasters? Are they really continues?


Reply to this email directly or view it on GitHub: https://github.com/nextgis/molusce/issues/4#issuecomment-98050794

KolesovDmitry commented 9 years ago

Next week I'll write a function for check types of initial and final state rasters. It will prevent calculation on continues rasters, but it certainly will not help you to model your data :) As far as I see, MOLUSCE can't help you much in your work -- MOLUSCE is developed for different problems. As far as I understand your description, I would advice 1) find the difference between the final and initial rasters Diff = final - init 2) build regression Diff ~ factors. I'll write more about it to your email address.

somaiyehnasrollahzadeh commented 5 years ago

Hi Dear Demitry I have the same problem about value in Molusce plugin. may i know how was the solution fo your problem ?

KolesovDmitry commented 5 years ago

The latest version of the plug-in has code for Virginia's issue. (The issue was fixed two years ago). So you (probably) have other cause for the error message. Could you provide us full information about your case? (The error message, types of input rasters etc)

somaiyehnasrollahzadeh commented 5 years ago

Hi Dear Dmitry  Thanks for your reply. My problem is that, when I am going to start validation and get kappa coefficient, I'll see this error  : An error has occurred while executing Python code:

MemoryError Traceback (most recent call last):   File "C:/Users/S.NASRZ/.qgis2/python/plugins\molusce\moluscedialog.py", line 632, in startValidation     reference = Raster(unicode(self.leReferenceMapPath.text()))   File "C:/Users/S.NASRZ/.qgis2/python/plugins\molusce\algorithms\dataprovider.py", line 54, in init     if self.filename: self._read()   File "C:/Users/S.NASRZ/.qgis2/python/plugins\molusce\algorithms\dataprovider.py", line 287, in _read     self.bands = np.ma.zeros((data.RasterCount,self.geodata['ySize'], self.geodata['xSize']), dtype=float)   File "C:\OSGeo4W\apps\Python27\lib\site-packages\numpy\ma\core.py", line 7887, in call     result = self._func.call(*args, **params).view(MaskedArray) MemoryError

and i couldnt add the spatial variable such as distance to roads. because it keeps giving me error about geometry not matched. so i just used one of the landuses.

It would be so kind of you to help me to solve my problem .

Best Regards Somaiyeh  Here I've attached my errors. and ill send the rasters via wetransfer. 

‎19‎ ‎Kasım‎ ‎2018‎ ‎Pazartesi‎ ‎21‎:‎44‎:‎20‎ ‎+0330 tarihinde, Dmitry Kolesov <notifications@github.com>şunu yazdı:  

The latest version of the plug-in has code for Virginia's issue. (The issue was fixed two years ago). So you (probably) have other cause for the error message. Could you provide us full information about your case? (The error message, types of input rasters etc)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Agnes438 commented 4 years ago

2020-06-24T14:33:15 1 Traceback (most recent call last): File "C:/Users/praveen/.qgis2/python/plugins\molusce\moluscedialog.py", line 444, in updateStatisticsTableDone self.drawTransitionStat() File "C:/Users/praveen/.qgis2/python/plugins\molusce\moluscedialog.py", line 1058, in drawTransitionStat stat = self.inputs["crosstab"].getTransitionStat() File "C:/Users/praveen/.qgis2/python/plugins\molusce\algorithms\models\crosstabs\manager.py", line 79, in getTransitionStat initArea = tab.getSumRows() File "C:/Users/praveen/.qgis2/python/plugins\molusce\algorithms\models\crosstabs\model.py", line 125, in getSumRows crosstable = self.getCrosstable() File "C:/Users/praveen/.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() Hi Sir, I am getting this error msg while calculating changes. can u help me to find where I am making mistake?

oliviervanwarmerdam commented 3 years ago

Hola, I do have the same error as Agnes438.

File "C:/Users/praveen/.qgis2/python/plugins\molusce\algorithms\models\crosstabs\model.py", line 125, in getSumRows crosstable = self.getCrosstable() File "C:/Users/praveen/.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()

Is there a way to solve this one? Really looking to your answer!!

Regards, Olivier