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

What should I do if one class is missing from one of the input maps #12

Open lluisvicens opened 8 years ago

lluisvicens commented 8 years ago

Corine layers: corine.zip

I'm trying to perform an analysis of land use/cover change detection using QGIS and MOLUSCE but I get an error message. I'm working with two CORINE raster layers (1990 vs 2006) and other two optional layers as a Spatial variables (distance to roads, distance to rivers). I successfully completed the "Inputs" and "Evaluating Correlation" tabs processes, but when I get to "Area Changes" tab, and I press the "Update tables" or "Create changes map", I always get the same python error message:

Here it goes the error log message:

2016-04-01T12:49:16 1 Traceback (most recent call last): File "/home/lluis/.qgis2/python/plugins/molusce/moluscedialog.py", line 413, in updateStatisticsTableDone self.drawTransitionStat() File "/home/lluis/.qgis2/python/plugins/molusce/moluscedialog.py", line 1027, in drawTransitionStat stat = self.inputs["crosstab"].getTransitionStat() File "/home/lluis/.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 (25,) (21,)

I'm working with QGIS 2.14.1 and MOLUSCE 3.0.11 under Ubuntu 14.04 LTS. I've tried the same on a Windows machine with same error message. Thanks.

KolesovDmitry commented 8 years ago

@lluisvicens , you have different landuse types in your data:

For example, landuse types '4', '6' are not presented in the second raster. It means that the module can't calculate transition statistics

lluisvicens commented 8 years ago

Thanks Dmitry for your answer and help.

May I do a question? Then point is, how can I proceed when for instance, a class in the initial layer has disappeared in the final layer (such as burnt area)? How should I detect and compute how the rest of the classes have changed in a period of time? If a single land cover class disappears within a period, is this meaning that there is no possibility to continue with the land cover change analysis?

KolesovDmitry commented 8 years ago

@lluisvicens , I don't know answers for your questions :( For the current state of the module the init-raster and final-raster must have the same landuse classes. Probably the issue can be solved with small code change, but I'm not sure.

We have developed the module using the next assumptions and user story:

We expect that the model works in constant enviroment (there aren't sudden changes in factors and external medium). For example if an user studies deforestation and some parts of the territory became a National park in the studied time period, the module isn't applicable (external medium have changed). More precisely the limits of the models are (we assumed that):

In case of your question. Actually we haven't thought about such possibility as elimination of a landuse class during the landuse evaluation process.

In your case you have N% of transition Class1->Class2 for the firs pair of rasters (init-final), but you don't have even one pixel for make the transition for the second pairs of rasters (final-new). As result, the model became inapplicable (and we haven't programmed this possibility)... But on the other hand I don't see a fundamental objection to use a trained model without the disappeared landuse class.

The main question is: can be the trained model applicable in such condition or can't be. I don't know, I have to think about it :)

simgislab commented 8 years ago

Then point is, how can I proceed when for instance, a class in the initial layer has disappeared in the final layer (such as burnt area)? How should I detect and compute how the rest of the classes have changed in a period of time? If a single land cover class disappears within a period, is this meaning that there is no possibility to continue with the land cover change analysis?

@lluisvicens I'd suppose there an easy answer to your question, turn your 'disappearing' class to NODATA before running the analysis

simgislab commented 8 years ago

I've added another issue to provide more informative error message

lluisvicens commented 8 years ago

A lot of thanks Maxim and Dmitry for your kind reply. I will take in consideration your hints, and in the meantime I won't consider the 'disappearing classes' between init-raster and final-raster and I will focus the analysis on the classes that are present on both layers.

I will keep an eye on future versions on MOLUSCE, just in case... ;) Thanks!