qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.52k stars 2.99k forks source link

Processing: Cannot choose attribute for "Class Identifier" in SAGA Supervised Classification for Grids #44828

Closed samuel-rosa closed 1 year ago

samuel-rosa commented 3 years ago

What is the bug or the crash?

I am using SAGA-GIS tool Supervised Classification for Grids. One of the options of this tool is Class Identifier. It serves the purpose of indicating which of the fields of Training Areas, an optional input shape, contains the definitions of the classes. The SAGA-GIS version 7.3.0 does not enable the selection of that field. Instead, the dropdown list shows all available shape layers. As a consequence, the classification algorithm does not run.

Steps to reproduce the issue

The figure below shows the SAGA-GIS tool Supervised Classification for Grids. The options Class Identifier does not show the fields contained in the attribute table of the shape treinamento.

Screenshot from 2021-08-24 16-22-36

This is different from SAGA-GIS itself as shown in the figure below:

Screenshot from 2021-08-24 16-35-58

The shape used is available at https://cloud.utfpr.edu.br/index.php/s/OoMQk3wRcMJEazJ

Versions

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

QGIS version | 3.16.4-Hannover | QGIS code branch | Release 3.16 -- | -- | -- | -- Compiled against Qt | 5.12.8 | Running against Qt | 5.12.8 Compiled against GDAL/OGR | 3.2.1 | Running against GDAL/OGR | 3.2.1 Compiled against GEOS | 3.9.0-CAPI-1.16.2 | Running against GEOS | 3.9.0-CAPI-1.16.2 Compiled against SQLite | 3.31.1 | Running against SQLite | 3.31.1 PostgreSQL Client Version | 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1) | SpatiaLite Version | 5.0.0 QWT Version | 6.1.4 | QScintilla2 Version | 2.11.2 Compiled against PROJ | 7.2.1 | Running against PROJ | Rel. 7.2.1, January 1st, 2021 OS Version | Ubuntu 20.04.2 LTS Active python plugins | togglegroupvisibility; quick_map_services; processing_r; pointsamplingtool; mapbiomascollection; qfieldsync; QuickOSM; processing; db_manager; MetaSearch

Additional context

I am happy to provide more info if needed.

roya0045 commented 3 years ago

@samuel-rosa Note that your SAGA version and the one native to qgis are different. You can try the plugin to see if this is better.

samuel-rosa commented 3 years ago

@roya0045 I did not understand what you meant by You can try the plugin to see if this is better. Could you please provide more detail?

samuel-rosa commented 3 years ago

@roya0045 I now see that there is a standalone SAGA plugin provided by North Road. I was not aware of this and will give a try.

samuel-rosa commented 3 years ago

@roya0045, I tested Processing Saga NextGen Provider: works like a charm! Thanks for pointing this plugin out.

I noticed that it is experimental. Will it replace the one native to QGIS?

roya0045 commented 3 years ago

@samuel-rosa This might shed some light on the situation https://github.com/qgis/QGIS-Enhancement-Proposals/issues/230

agiudiceandrea commented 3 years ago

@gioman the issue is in the description file SupervisedClassificationforGrids.txt at line: QgsProcessingParameterFeatureSource|TRAINING_CLASS|Class Identifier|5|None|False I think It should be: QgsProcessingParameterField|TRAINING_CLASS|Class Identifier|None|TRAINING|-1|False|False or (if optional) QgsProcessingParameterField|TRAINING_CLASS|Class Identifier|None|TRAINING|-1|False|True

Also the line: QgsProcessingParameterFeatureSource|TRAINING|Training Areas|-1|None|True should be changed to: QgsProcessingParameterFeatureSource|TRAINING|Training Areas|2|None|True because the TRAINING parameter should only accept polygon type layer

gioman commented 3 years ago

@gioman the issue is in the description file SupervisedClassificationforGrids.txt at line:

@agiudiceandrea yes I know. But the real problem is the description files pulled from the SAGA project, which are frequently wrong or are not split (because of incompatible parameters that cannot be used at the same time). I plan make a PR and ask to re-instate to control on our side the description files, so we can patch them when necessary.

agiudiceandrea commented 3 years ago

@gioman in this case the description file pulled from the SAGA project correctly use QgsProcessingParameterField for the TRAINING_CLASS option, while the one shipped by QGIS incorrectly use QgsProcessingParameterFeatureSource.

AFAIK, the SAGA algs description file pulled from the SAGA project are only used for QGIS installed on Windows via the new OSGeo4W v2 repository, while the ones provided by QGIS are used with the old OSGeo4W v1 repository on Windows and for the GNU/Linux and macOS distributions, instead.

There is also another issue: the SAGA algs change their parameters from one SAGA version to another. In fact in this case, the description file provided by QGIS misses the output CLASSES_LUT which was introduced since SAGA 7.7.0...

gioman commented 3 years ago

AFAIK, the SAGA algs description file pulled from the SAGA project are only used for QGIS installed on Windows via the new OSGeo4W v2 repository, while the ones provided by QGIS are used with the old OSGeo4W v1 repository on Windows and for the GNU/Linux and macOS distributions, instead.

@agiudiceandrea this is also my understanding, and is not really sustainable. This is why we must revert to control the description file on all the platforms/installers.

There is also another issue: the SAGA algs change their parameters from one SAGA version to another. In fact in this case, the description file provided by QGIS misses the output CLASSES_LUT which was introduced since SAGA 7.7.0...

this is a long known issue, since SAGA was added to Processing. And one of the reasons why SAGA will move out of core. But until there we must try to support as best as we can the users.

alexbruy commented 3 years ago

FYI, there is a QEP related to this.

roya0045 commented 3 years ago

FYI, there is a QEP related to this.

I linked it previously ;)

alexbruy commented 1 year ago

SAGA Provider was not maintained and now remowed from QGIS (see #50834). Users are encouraged to use the 3rd-party plugins instead.