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.65k stars 3.01k forks source link

Signatures created with i.cluster cannot be found by i.maxlik #58816

Open dhdeangelis opened 2 months ago

dhdeangelis commented 2 months ago

What is the bug or the crash?

In running image classification using GRASS modules i.cluster and i.maxlik, the latter cannot find the signature created by i.cluster. This in spite of the file being created and stored correctly.

Steps to reproduce the issue

  1. open a set of 2 or more rasters covering the same area and with the same pixel size but different in content (i.e. different bands of one and same satellite image scene)

  2. run i.cluster to create a signature file

    
    QGIS version: 3.39.0-Master
    Qt version: 6.7.2
    Python version: 3.11.9
    GDAL version: 3.9.2
    GEOS version: 3.12.2-CAPI-1.18.2
    PROJ version: Rel. 9.4.1, June 1st, 2024
    GRASS version: 8.5.0dev
    Algorithm started at: 2024-09-20T12:20:15
    Algorithm 'i.cluster' starting…
    Input parameters:
    { 'GRASS_REGION_CELLSIZE_PARAMETER' : 0, 'GRASS_REGION_PARAMETER' : None, 'classes' : 10, 'convergence' : 98, 'input' : ['/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B01_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B02_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B03_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B04_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B05_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B06_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B07_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B11_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B12_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B8A_20m.tif'], 'iterations' : 30, 'min_size' : 17, 'reportfile' : 'TEMPORARY_OUTPUT', 'sample' : '', 'seed' : None, 'separation' : 0, 'signaturefile' : '/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/sigs.txt' }

g.proj -c wkt="/tmp/processing_HUoSRA/2d3bdda5c2214bcb9b23d550215b4b7c/crs.prj" r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B01_20m.tif" band=1 output="rast_66ed4c5fb88972" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B02_20m.tif" band=1 output="rast_66ed4c5fb89123" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B03_20m.tif" band=1 output="rast_66ed4c5fb897a4" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B04_20m.tif" band=1 output="rast_66ed4c5fb89e05" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B05_20m.tif" band=1 output="rast_66ed4c5fb8a466" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B06_20m.tif" band=1 output="rast_66ed4c5fb8aab7" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B07_20m.tif" band=1 output="rast_66ed4c5fb8b2d8" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B11_20m.tif" band=1 output="rast_66ed4c5fb8ba49" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B12_20m.tif" band=1 output="rast_66ed4c5fb8c0d10" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B8A_20m.tif" band=1 output="rast_66ed4c5fb8c7211" --overwrite -o g.region n=9431740.0 s=9417320.0 e=523020.0 w=504780.0 res=20.0 i.group group=group_66ed4c5fb96e412 subgroup=subgroup_66ed4c5fb975d13 input=rast_66ed4c5fb88972,rast_66ed4c5fb89123,rast_66ed4c5fb897a4,rast_66ed4c5fb89e05,rast_66ed4c5fb8a466,rast_66ed4c5fb8aab7,rast_66ed4c5fb8b2d8,rast_66ed4c5fb8ba49,rast_66ed4c5fb8c0d10,rast_66ed4c5fb8c7211 i.cluster classes=10 iterations=30 convergence=98 separation=0 min_size=17 group="group_66ed4c5fb96e412" subgroup="subgroup_66ed4c5fb975d13" signaturefile="sigs.txt" reportfile="/tmp/processing_HUoSRA/7efa895b9ae740bbb2134786a02e643a/reportfile.txt" --overwrite mkdir -p "/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik" mv -f "/tmp/processing_HUoSRA/grassdata/temp_location/PERMANENT/signatures/sig/sigs.txt/sig" "/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/sigs.txt" Default region was updated to the new projection, but if you have multiple mapsets g.region -d should be run in each to update the region from the default Projection information updated Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Adding raster map rast_66ed4c5fb88972@PERMANENT to group Adding raster map rast_66ed4c5fb89123@PERMANENT to group Adding raster map rast_66ed4c5fb897a4@PERMANENT to group Adding raster map rast_66ed4c5fb89e05@PERMANENT to group Adding raster map rast_66ed4c5fb8a466@PERMANENT to group Adding raster map rast_66ed4c5fb8aab7@PERMANENT to group Adding raster map rast_66ed4c5fb8b2d8@PERMANENT to group Adding raster map rast_66ed4c5fb8ba49@PERMANENT to group Adding raster map rast_66ed4c5fb8c0d10@PERMANENT to group Adding raster map rast_66ed4c5fb8c7211@PERMANENT to group Adding raster map rast_66ed4c5fb88972@PERMANENT to subgroup Adding raster map rast_66ed4c5fb89123@PERMANENT to subgroup Adding raster map rast_66ed4c5fb897a4@PERMANENT to subgroup Adding raster map rast_66ed4c5fb89e05@PERMANENT to subgroup Adding raster map rast_66ed4c5fb8a466@PERMANENT to subgroup Adding raster map rast_66ed4c5fb8aab7@PERMANENT to subgroup Adding raster map rast_66ed4c5fb8b2d8@PERMANENT to subgroup Adding raster map rast_66ed4c5fb8ba49@PERMANENT to subgroup Adding raster map rast_66ed4c5fb8c0d10@PERMANENT to subgroup Adding raster map rast_66ed4c5fb8c7211@PERMANENT to subgroup Reading raster maps... 2..5..8..11..14..17..20..23..26..29..32..35..38..41..44..47..50..53..56..59..62..65..68..71..74..77..80..83..86..89..92..95..98..100 i.cluster complete. File created. Execution completed in 1.25 seconds Results: signaturefile: /home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/sigs.txt reportfile: /tmp/processing_HUoSRA/7efa895b9ae740bbb2134786a02e643a/reportfile.txt

Loading resulting layers Algorithm 'i.cluster' finished


3. run i.maxlik to classify the set

QGIS version: 3.39.0-Master Qt version: 6.7.2 Python version: 3.11.9 GDAL version: 3.9.2 GEOS version: 3.12.2-CAPI-1.18.2 PROJ version: Rel. 9.4.1, June 1st, 2024 GRASS version: 8.5.0dev Algorithm started at: 2024-09-20T12:21:35 Algorithm 'i.maxlik' starting… Input parameters: { 'GRASS_RASTER_FORMAT_META' : '', 'GRASS_RASTER_FORMAT_OPT' : '', 'GRASS_REGION_CELLSIZE_PARAMETER' : 0, 'GRASS_REGION_PARAMETER' : None, 'input' : ['/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B01_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B02_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B03_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B04_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B05_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B06_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B07_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B11_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B12_20m.tif','/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B8A_20m.tif'], 'output' : 'TEMPORARY_OUTPUT', 'reject' : 'TEMPORARY_OUTPUT', 'signaturefile' : '/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/sigs.txt' }

g.proj -c wkt="/tmp/processing_HUoSRA/d16369a8242c475f856ae41e10a1de12/crs.prj" r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B01_20m.tif" band=1 output="rast_66ed4caf8a79914" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B02_20m.tif" band=1 output="rast_66ed4caf8a7df15" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B03_20m.tif" band=1 output="rast_66ed4caf8a81a16" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B04_20m.tif" band=1 output="rast_66ed4caf8a85317" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B05_20m.tif" band=1 output="rast_66ed4caf8a88d18" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B06_20m.tif" band=1 output="rast_66ed4caf8a8c519" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B07_20m.tif" band=1 output="rast_66ed4caf8a90020" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B11_20m.tif" band=1 output="rast_66ed4caf8a93821" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B12_20m.tif" band=1 output="rast_66ed4caf8a97822" --overwrite -o r.in.gdal input="/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/T37MEQ_20240429T072621_B8A_20m.tif" band=1 output="rast_66ed4caf8a9b223" --overwrite -o g.region n=9431740.0 s=9417320.0 e=523020.0 w=504780.0 res=20.0 i.group group=group_66ed4caf8ad3d24 subgroup=subgroup_66ed4caf8ad7125 input=rast_66ed4caf8a79914,rast_66ed4caf8a7df15,rast_66ed4caf8a81a16,rast_66ed4caf8a85317,rast_66ed4caf8a88d18,rast_66ed4caf8a8c519,rast_66ed4caf8a90020,rast_66ed4caf8a93821,rast_66ed4caf8a97822,rast_66ed4caf8a9b223 mkdir -p "/tmp/processing_HUoSRA/grassdata/temp_location/PERMANENT/group/group_66ed4caf8ad3d24/subgroup/subgroup_66ed4caf8ad7125/sig" cp -f "/home/hernan/GeoNatura/proy/HaV_Rymddata/2024_WIO-RS/testQGIS_maxLik/sigs.txt" "/tmp/processing_HUoSRA/grassdata/temp_location/PERMANENT/group/group_66ed4caf8ad3d24/subgroup/subgroup_66ed4caf8ad7125/sig/sigs.txt" i.maxlik signaturefile="sigs.txt" group="group_66ed4caf8ad3d24" subgroup="subgroup_66ed4caf8ad7125" output=output885121574fe842e895c5d83dadf657de reject=reject885121574fe842e895c5d83dadf657de --overwrite g.region raster=output885121574fe842e895c5d83dadf657de r.out.gdal -t -m input="output885121574fe842e895c5d83dadf657de" output="/tmp/processing_HUoSRA/e104d25f4f2d4980bd6fbd6d562684b0/output.tif" format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite g.region raster=reject885121574fe842e895c5d83dadf657de r.out.gdal -t -m input="reject885121574fe842e895c5d83dadf657de" output="/tmp/processing_HUoSRA/23c833bb06844382a1629eed21181366/reject.tif" format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite Default region was updated to the new projection, but if you have multiple mapsets g.region -d should be run in each to update the region from the default Projection information updated Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Over-riding projection check Importing raster map ... 0..3..6..9..12..15..18..21..24..27..30..33..36..39..42..45..48..51..54..57..60..63..66..69..72..75..78..81..84..87..90..93..96..99..100 Adding raster map rast_66ed4caf8a79914@PERMANENT to group Adding raster map rast_66ed4caf8a7df15@PERMANENT to group Adding raster map rast_66ed4caf8a81a16@PERMANENT to group Adding raster map rast_66ed4caf8a85317@PERMANENT to group Adding raster map rast_66ed4caf8a88d18@PERMANENT to group Adding raster map rast_66ed4caf8a8c519@PERMANENT to group Adding raster map rast_66ed4caf8a90020@PERMANENT to group Adding raster map rast_66ed4caf8a93821@PERMANENT to group Adding raster map rast_66ed4caf8a97822@PERMANENT to group Adding raster map rast_66ed4caf8a9b223@PERMANENT to group Adding raster map rast_66ed4caf8a79914@PERMANENT to subgroup Adding raster map rast_66ed4caf8a7df15@PERMANENT to subgroup Adding raster map rast_66ed4caf8a81a16@PERMANENT to subgroup Adding raster map rast_66ed4caf8a85317@PERMANENT to subgroup Adding raster map rast_66ed4caf8a88d18@PERMANENT to subgroup Adding raster map rast_66ed4caf8a8c519@PERMANENT to subgroup Adding raster map rast_66ed4caf8a90020@PERMANENT to subgroup Adding raster map rast_66ed4caf8a93821@PERMANENT to subgroup Adding raster map rast_66ed4caf8a97822@PERMANENT to subgroup Adding raster map rast_66ed4caf8a9b223@PERMANENT to subgroup ERROR: Unable to open signature file ERROR: Raster map not found ERROR: Raster map or group not found ERROR: Raster map not found ERROR: Raster map or group not found ERROR: Raster map not found ERROR: Raster map or group not found ERROR: Raster map not found ERROR: Raster map or group not found Execution completed in 1.68 seconds Results: output: /tmp/processing_HUoSRA/e104d25f4f2d4980bd6fbd6d562684b0/output.tif reject: /tmp/processing_HUoSRA/23c833bb06844382a1629eed21181366/reject.tif

Loading resulting layers The following layers were not correctly generated. • /tmp/processing_HUoSRA/23c833bb06844382a1629eed21181366/reject.tif • /tmp/processing_HUoSRA/e104d25f4f2d4980bd6fbd6d562684b0/output.tif You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.


5. See error:

ERROR: Unable to open signature file



But the file exists, can be opened correctly, and is similar to the one created natively in a GRASS session with the same input.

### Versions

<table width='100%' align='center'><tr><td colspan="2"><b>Libraries</b></td><tr><td>QGIS version</td><td>3.39.0-Master</td>QGIS code branch<td><a href="https://github.com/qgis/QGIS/tree/master">master</a></td></tr><tr><td>Qt version</td><td>6.7.2</td></tr><tr><td>Python version</td><td>3.11.9 (Compiled)<br/>3.11.10 (Running)</td></tr><tr><td>GDAL/OGR version</td><td>3.9.2</td></tr><tr><td>PROJ version</td><td>9.4.1</td></tr><tr><td>EPSG Registry database version</td><td>v11.006 (2024-03-13)</td></tr><tr><td>GEOS version</td><td>3.12.2-CAPI-1.18.2</td></tr><tr><td>SQLite version</td><td>3.46.0</td></tr><tr><td>PostgreSQL client version</td><td>No support</td></tr><tr><td>SpatiaLite version</td><td>5.1.0</td></td></tr><tr><td>QWT version</td><td>6.3.0</td></tr><tr><td>QScintilla2 version</td><td>2.14.1</td></tr><tr><td>OS version</td><td>openSUSE Tumbleweed</td></tr><tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2"><b>Active Python plugins</b></td></tr><tr><td>db_manager</td><td>0.1.20</td></tr><tr><td>processing</td><td>2.12.99</td></tr><tr><td>grassprovider</td><td>2.12.99</td></tr><tr><td>MetaSearch</td><td>0.3.6</td></tr></table>

### Supported QGIS version

- [ ] I'm running a supported QGIS version according to [the roadmap](https://www.qgis.org/en/site/getinvolved/development/roadmap.html#release-schedule).

### New profile

- [ x] I tried with a new [QGIS profile](https://docs.qgis.org/latest/en/docs/user_manual/introduction/qgis_configuration.html#working-with-user-profiles)

### Additional context

Note that I am aware of errors previously reported and fixed with related issues that affected Windows computers and which character was used to build the path string. This is not the case here. I am working on Linux and the file is created OK. 
Also note that a similar process using the same input data but run natively in GRASS works well.
agiudiceandrea commented 2 months ago

@dhdeangelis, thanks for reporting. It would be very useful if you provided a minimal sample dataset and algorithm's parameters in order to replicate the issue.

dhdeangelis commented 2 months ago

Thank you, @agiudiceandrea

In this link you will find a zip file containing a subset of a Sentinel-2 MSI (L2A) scene at 20 m pixel size composed of 10 bands (B1..8A, B11, B12):

Archive:  example.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
  1316550  2024-09-20 09:49   T37MEQ_20240429T072621_B01_20m.tif
  1316550  2024-09-20 09:49   T37MEQ_20240429T072621_B02_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B03_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B04_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B05_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B06_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B07_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B11_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B12_20m.tif
  1316550  2024-09-20 09:50   T37MEQ_20240429T072621_B8A_20m.tif
---------                     -------
 13165500                     10 files

I tested many parameters. You can hopefully reproduce the error using:

  1. i.cluster: select the 10 images, choose 10 classes, rest left as default (30 iterations, 98% convergence, etc), give the name and location of the output signature file (in my example 'sigs.txt'). Note that this is not the problem.
  2. i.maxlik: select the 10 images, select the signature file produced by i.cluster. This is the step producing the error: ERROR: Unable to open signature file <sigs.txt>
dhdeangelis commented 2 months ago

For reference, note that the following sequence of GRASS commands, equivalent to the set of instructions given above, works correctly on the same dataset and options as above when run from a native GRASS session, in the same machine of course:

i.group group=test input=B01,B02,B03,B04,B05,B06,B07,B8A,B11,B12
i.group group=test subgroup=test_subg input=B01,B02,B03,B04,B05,B06,B07,B8A,B11,B12
i.cluster group=test subgroup=test_subg signaturefile=sigFile classes=10 --overwrite
i.maxlik group=test subgroup=test_subg signaturefile=sigFile output=test_MaxLik --overwrite
agiudiceandrea commented 2 months ago

@dhdeangelis, since GRASS-GIS 8 there was a change in the location of the signature file. It looks like there was an oversight in PR https://github.com/qgis/QGIS/pull/56196 which fixed the signature exporting for GRASS-GIS 8.x, but forgot to also fix the signature importing.

While I cannot currently directly test on Linux, you can fix the ERROR: Unable to open signature file <sigs.txt> issue by changing the following lines of the file i.py in the python\plugins\grassprovider\ext subfolder of the QGIS installation folder:

https://github.com/qgis/QGIS/blob/08da370d35440b1ded1d5f7c67ebe7536eb6bc45/python/plugins/grassprovider/ext/i.py#L118-L128

to:

def importSigFile(alg, group, subgroup, src, sigDir='sig'):
    """
    Import a signature file into an
    internal GRASSDB folder
    """
    shortSigFile = os.path.basename(src)

    grass_version = int(GrassUtils.installedVersion().split('.')[0])
    if grass_version >= 8:
        interSig = os.path.join(GrassUtils.grassMapsetFolder(),
                                'PERMANENT', 'signatures',
                                sigDir, shortSigFile, 'sig')
    else:
        interSig = os.path.join(GrassUtils.grassMapsetFolder(),
                                'PERMANENT', 'group', group, 'subgroup',
                                subgroup, sigDir, shortSigFile)
    copyFile(alg, src, interSig)
    return shortSigFile

Anyway, unfortunately it looks like it is actually impossible to use the signature file created by the QGIS processing algorithm i.cluster in a subsequent run of the QGIS processing algorithm i.maxlik: in fact, when i.cluster runs, then the raster layers are imported in a GRASS temporary location with names as rast_66edebdb3669a38, rast_66edebdb36a8239, rast_66edebdb3724d40, ... (and a group and subgroup are created with names as group_66ed4caf8ad3d24 subgroup_66ed4caf8ad7125) and such raster names are written in the signature file; when i.maxlik runs, then the raster layers are again imported in the same GRASS temporary location, and group and subgroup are created, but with different names than the ones imported and created by the previous run of i.cluster, so there is a mismatch between the raster layers' names used by i.maxlik and the raster layers' names stored in the signature file...

dhdeangelis commented 2 months ago

@agiudiceandrea thank you for the good detective work. Why are those names necessary after all? Why not simply use the same layer names given within the QGIS session for the QGIS-GRASS related operations?

agiudiceandrea commented 2 months ago

Maybe @nilason could give some hints about how to correctly handle the new type of signature files (GRASS >= 8.0 https://github.com/OSGeo/grass/pull/1501) when using i.cluster / i.maxlik with the GRASS-GIS processing provider.

nilason commented 2 months ago

Maybe @nilason could give some hints about how to correctly handle the new type of signature files (GRASS >= 8.0 OSGeo/grass#1501) when using i.cluster / i.maxlik with the GRASS-GIS processing provider.

For possibly getting the best answer to this I forward this to @marisn

marisn commented 1 month ago

Anyway, unfortunately it looks like it is actually impossible to use the signature file created by the QGIS processing algorithm i.cluster in a subsequent run of the QGIS processing algorithm i.maxlik: in fact, when i.cluster runs, then the raster layers are imported in a GRASS temporary location with names as rast_66edebdb3669a38, rast_66edebdb36a8239, rast_66edebdb3724d40, ... (and a group and subgroup are created with names as group_66ed4caf8ad3d24 subgroup_66ed4caf8ad7125) and such raster names are written in the signature file; when i.maxlik runs, then the raster layers are again imported in the same GRASS temporary location, and group and subgroup are created, but with different names than the ones imported and created by the previous run of i.cluster, so there is a mismatch between the raster layers' names used by i.maxlik and the raster layers' names stored in the signature file...

This analysis is correct. GRASS 8 has built-in mechanism of mapping signature values to correct bands. It is done by comparing raster semantic labels. If raster semantic labels are absent, then raster layer names must be identical. Thus QGIS could just set correct semantic labels and signature files will work just fine. See an example in i.cluster documentation: r.support map=lsat7_2002_10 semantic_label=TM7_1 Thus work flow should be: Import->r.support->i.cluster Import->r.support->i.maxlik. Raster semantic label is just a plain string – anything goes (following some structure is suggested). Of course then it is up to QGIS to ensure that bands are mapped to correct labels on second import (RGBNir is still RGBNir and not e.g. NirRGB)

marisn commented 1 month ago

Forgot to add – the same applies to i.gensig, i.gensigset, i.smap, i.svm.train and i.svm.predict.