[GRASS-user] Question with algorithm 'r.mapcalc.simple' from QGIS GUI
Valter Albino
valteralbino at gmail.com
Sun Apr 5 11:50:38 PDT 2020
I can see it [https://grass.osgeo.org/grass78/manuals/r.mapcalc.html].
Altought for the example that was presented the syntax doesn't work, it's a
fine solution, thanks Pedro!
Cumprimentos,
*Valter Albino -* Geógrafo Físico, M.Sc.
Modelação H&H / Riscos ambientais / OT&U
www.valteralbino.wixsite.com/hydrodynamics
Pedro Venâncio <pedrongvenancio gmail.com> escreveu no dia domingo,
5/04/2020 à(s) 19:31:
> Valter logical and in GRASS is &&.
>
> Best regards,
> Pedro
>
>
> A domingo, 5/04/2020, 19:11, Valter Albino <valteralbino gmail.com>
> escreveu:
>
>> OK, it doesn't support this type of function: "Undefined function
>> 'logical_and'"
>> Hey, but GDAL raster calculator in QGIS GUI does!
>>
>> Cumprimentos,
>> *Valter Albino -* Geógrafo Físico, M.Sc.
>> Modelação H&H / Riscos ambientais / OT&U
>> www.valteralbino.wixsite.com/hydrodynamics
>>
>>
>> Valter Albino <valteralbino gmail.com> escreveu no dia domingo,
>> 5/04/2020 à(s) 18:50:
>>
>>> Hi
>>>
>>> Searching for a solution do compute a simple "if else" expression with
>>> 'r.mapcalc.simple' from QGIS GUI.
>>> Don't understand the following message. Someone have any clue?
>>>
>>> QGIS version: 3.12.1-București
>>>
>>> QGIS code revision: 121cc00ff0
>>>
>>> Qt version: 5.11.2
>>>
>>> GDAL version: 3.0.4
>>>
>>> GEOS version: 3.8.1-CAPI-1.13.3
>>>
>>> PROJ version: Rel. 6.3.1, February 10th, 2020
>>>
>>> Processing algorithm…
>>>
>>> Algorithm 'r.mapcalc.simple' starting…
>>>
>>> Input parameters:
>>>
>>> { 'GRASS_RASTER_FORMAT_META' : '', 'GRASS_RASTER_FORMAT_OPT' : '',
>>> 'GRASS_REGION_CELLSIZE_PARAMETER' : 5, 'GRASS_REGION_PARAMETER' :
>>> '-59062.1289,-38278.9651,-78283.947,-59308.1937 [EPSG:3763]', 'a' :
>>> 'H:/recLUvalue.tif', 'b' : 'H:/recSoilNu.tif', 'c' : None, 'd' : None, 'e'
>>> : None, 'expression' : '99*(A==1) + 91*logical_and(A==2, B==1) +
>>> 94*logical_and(A==2, B==2) + 96*logical_and(A==2, B==3) +
>>> 97*logical_and(A==2, B==4) + 93*logical_and(A==3, B==1) +
>>> 95*logical_and(A==3, B==2) + 97*logical_and(A==3, B==3) +
>>> 97*logical_and(A==3, B==4) + 91*logical_and(A==4, B==1) +
>>> 94*logical_and(A==4, B==2) + 96*logical_and(A==4, B==3) +
>>> 97*logical_and(A==4, B==4) + 78*logical_and(A==5, B==1) +
>>> 86*logical_and(A==5, B==2) + 91*logical_and(A==5, B==3) +
>>> 92*logical_and(A==5, B==4) + 100*(A==1) + 79*logical_and(A==8, B==1) +
>>> 87*logical_and(A==8, B==2) + 91*logical_and(A==8, B==3) +
>>> 93*logical_and(A==8, B==4) + 78*logical_and(A==9, B==1) +
>>> 86*logical_and(A==9, B==1) + 91*logical_and(A==9, B==2) +
>>> 93*logical_and(A==9, B==3) + 72*logical_and(A==11, B==1) +
>>> 84*logical_and(A==11, B==2) + 90*logical_and(A==11, B==3) +
>>> 92*logical_and(A==11, B==4) + 45*logical_and(A==12, B==1) +
>>> 71*logical_and(A==12, B==2) + 79*logical_and(A==12, B==3) +
>>> 84*logical_and(A==12, B==4) + 50*logical_and(A==13, B==1) +
>>> 76*logical_and(A==13, B==2) + 85*logical_and(A==13, B==3) +
>>> 89*logical_and(A==13, B==4) + 75*logical_and(A==14, B==1) +
>>> 87*logical_and(A==14, B==2) + 93*logical_and(A==14, B==3) +
>>> 96*logical_and(A==14, B==4)', 'f' : None, 'output' : 'TEMPORARY_OUTPUT' }
>>>
>>>
>>> g.proj -c proj4="+proj=tmerc +lat_0=39.6682583333333
>>> +lon_0=-8.13310833333333 +k=1 +x_0=0 +y_0=0 +ellps=GRS80
>>> +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
>>>
>>> r.in.gdal input="H:\recLUvalue.tif" band=1 output="rast_5e8a18a12ad402"
>>> --overwrite -o
>>>
>>> r.in.gdal input="H:\recSoilNu.tif" band=1 output="rast_5e8a18a12ad403"
>>> --overwrite -o
>>>
>>> g.region n=-59308.1937 s=-78283.947 e=-38278.9651 w=-59062.1289 res=5.0
>>>
>>> r.mapcalc.simple a=rast_5e8a18a12ad402 b=rast_5e8a18a12ad403
>>> expression="99*(A==1) + 91*logical_and(A==2, B==1) + 94*logical_and(A==2,
>>> B==2) + 96*logical_and(A==2, B==3) + 97*logical_and(A==2, B==4) +
>>> 93*logical_and(A==3, B==1) + 95*logical_and(A==3, B==2) +
>>> 97*logical_and(A==3, B==3) + 97*logical_and(A==3, B==4) +
>>> 91*logical_and(A==4, B==1) + 94*logical_and(A==4, B==2) +
>>> 96*logical_and(A==4, B==3) + 97*logical_and(A==4, B==4) +
>>> 78*logical_and(A==5, B==1) + 86*logical_and(A==5, B==2) +
>>> 91*logical_and(A==5, B==3) + 92*logical_and(A==5, B==4) + 100*(A==1) +
>>> 79*logical_and(A==8, B==1) + 87*logical_and(A==8, B==2) +
>>> 91*logical_and(A==8, B==3) + 93*logical_and(A==8, B==4) +
>>> 78*logical_and(A==9, B==1) + 86*logical_and(A==9, B==1) +
>>> 91*logical_and(A==9, B==2) + 93*logical_and(A==9, B==3) +
>>> 72*logical_and(A==11, B==1) + 84*logical_and(A==11, B==2) +
>>> 90*logical_and(A==11, B==3) + 92*logical_and(A==11, B==4) +
>>> 45*logical_and(A==12, B==1) + 71*logical_and(A==12, B==2) +
>>> 79*logical_and(A==12, B==3) + 84*logical_and(A==12, B==4) +
>>> 50*logical_and(A==13, B==1) + 76*logical_and(A==13, B==2) +
>>> 85*logical_and(A==13, B==3) + 89*logical_and(A==13, B==4) +
>>> 75*logical_and(A==14, B==1) + 87*logical_and(A==14, B==2) +
>>> 93*logical_and(A==14, B==3) + 96*logical_and(A==14, B==4)"
>>> output=outputb7f2c5ec865148f6a92bddf859fdf839 --overwrite
>>>
>>> g.region raster=outputb7f2c5ec865148f6a92bddf859fdf839
>>>
>>> r.out.gdal -t -m input="outputb7f2c5ec865148f6a92bddf859fdf839"
>>> output="C:\Users\Particular\AppData\Local\Temp\processing_GWGaYw\1c703db4b0d14b2a88c0e57e10cf8d6e\output.tif"
>>> format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite
>>>
>>> Starting GRASS GIS...
>>>
>>> WARNING: Concurrent mapset locking is not supported on Windows
>>>
>>> Cleaning up temporary files...
>>>
>>> Executing
>>> <C:\Users\Particular\AppData\Local\Temp\processing_GWGaYw\grassdata\grass_batch_job.cmd>
>>> ...
>>>
>>> C:\Users\Particular\Documents>chcp 1252 1>NUL
>>>
>>> C:\Users\Particular\Documents>g.proj -c proj4="+proj=tmerc
>>> +lat_0=39.6682583333333 +lon_0=-8.13310833333333 +k=1 +x_0=0 +y_0=0
>>> +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
>>>
>>> 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
>>>
>>> C:\Users\Particular\Documents>r.in.gdal input="H:\recLUvalue.tif" band=1
>>> output="rast_5e8a18a12ad402" --overwrite -o
>>>
>>> Over-riding projection check
>>>
>>> Importing raster map <rast_5e8a18a12ad402>...
>>>
>>>
>>> 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
>>>
>>> C:\Users\Particular\Documents>r.in.gdal input="H:\recSoilNu.tif" band=1
>>> output="rast_5e8a18a12ad403" --overwrite -o
>>>
>>> Over-riding projection check
>>>
>>> Importing raster map <rast_5e8a18a12ad403>...
>>>
>>>
>>> 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
>>>
>>> C:\Users\Particular\Documents>g.region n=-59308.1937 s=-78283.947
>>> e=-38278.9651 w=-59062.1289 res=5.0
>>>
>>> C:\Users\Particular\Documents>r.mapcalc.simple a=rast_5e8a18a12ad402
>>> b=rast_5e8a18a12ad403 expression="99*(A==1) + 91*logical_and(A==2, B==1) +
>>> 94*logical_and(A==2, B==2) + 96*logical_and(A==2, B==3) +
>>> 97*logical_and(A==2, B==4) + 93*logical_and(A==3, B==1) +
>>> 95*logical_and(A==3, B==2) + 97*logical_and(A==3, B==3) +
>>> 97*logical_and(A==3, B==4) + 91*logical_and(A==4, B==1) +
>>> 94*logical_and(A==4, B==2) + 96*logical_and(A==4, B==3) +
>>> 97*logical_and(A==4, B==4) + 78*logical_and(A==5, B==1) +
>>> 86*logical_and(A==5, B==2) + 91*logical_and(A==5, B==3) +
>>> 92*logical_and(A==5, B==4) + 100*(A==1) + 79*logical_and(A==8, B==1) +
>>> 87*logical_and(A==8, B==2) + 91*logical_and(A==8, B==3) +
>>> 93*logical_and(A==8, B==4) + 78*logical_and(A==9, B==1) +
>>> 86*logical_and(A==9, B==1) + 91*logical_and(A==9, B==2) +
>>> 93*logical_and(A==9, B==3) + 72*logical_and(A==11, B==1) +
>>> 84*logical_and(A==11, B==2) + 90*logical_and(A==11, B==3) +
>>> 92*logical_and(A==11, B==4) + 45*logical_and(A==12, B==1) +
>>> 71*logical_and(A==12, B==2) + 79*logical_and(A==12, B==3) +
>>> 84*logical_and(A==12, B==4) + 50*logical_and(A==13, B==1) +
>>> 76*logical_and(A==13, B==2) + 85*logical_and(A==13, B==3) +
>>> 89*logical_and(A==13, B==4) + 75*logical_and(A==14, B==1) +
>>> 87*logical_and(A==14, B==2) + 93*logical_and(A==14, B==3) +
>>> 96*logical_and(A==14, B==4)" output=outputb7f2c5ec865148f6a92bddf859fdf839
>>> --overwrite
>>>
>>> Undefined function 'logical_and'
>>>
>>> Parse error
>>>
>>> ERROR: parse error
>>>
>>> ERROR: An error occurred while running r.mapcalc with expression:
>>> outputb7f2c5ec865148f6a92bddf859fdf839 = 99*(rast_5e8a18a12ad402==1) +
>>> 91*logical_and(rast_5e8a18a12ad402==2, rast_5e8a18a12ad403==1) +
>>> 94*logical_and(rast_5e8a18a12ad402==2, rast_5e8a18a12ad403==2) +
>>> 96*logical_and(rast_5e8a18a12ad402==2, rast_5e8a18a12ad403==3) +
>>> 97*logical_and(rast_5e8a18a12ad402==2, rast_5e8a18a12ad403==4) +
>>> 93*logical_and(rast_5e8a18a12ad402==3, rast_5e8a18a12ad403==1) +
>>> 95*logical_and(rast_5e8a18a12ad402==3, rast_5e8a18a12ad403==2) +
>>> 97*logical_and(rast_5e8a18a12ad402==3, rast_5e8a18a12ad403==3) +
>>> 97*logical_and(rast_5e8a18a12ad402==3, rast_5e8a18a12ad403==4) +
>>> 91*logical_and(rast_5e8a18a12ad402==4, rast_5e8a18a12ad403==1) +
>>> 94*logical_and(rast_5e8a18a12ad402==4, rast_5e8a18a12ad403==2) +
>>> 96*logical_and(rast_5e8a18a12ad402==4, rast_5e8a18a12ad403==3) +
>>> 97*logical_and(rast_5e8a18a12ad402==4, rast_5e8a18a12ad403==4) +
>>> 78*logical_and(rast_5e8a18a12ad402==5, rast_5e8a18a12ad403==1) +
>>> 86*logical_and(rast_5e8a18a12ad402==5, rast_5e8a18a12ad403==2) +
>>> 91*logical_and(rast_5e8a18a12ad402==5, rast_5e8a18a12ad403==3) +
>>> 92*logical_and(rast_5e8a18a12ad402==5, rast_5e8a18a12ad403==4) +
>>> 100*(rast_5e8a18a12ad402==1) + 79*logical_and(rast_5e8a18a12ad402==8,
>>> rast_5e8a18a12ad403==1) + 87*logical_and(rast_5e8a18a12ad402==8,
>>> rast_5e8a18a12ad403==2) + 91*logical_and(rast_5e8a18a12ad402==8,
>>> rast_5e8a18a12ad403==3) + 93*logical_and(rast_5e8a18a12ad402==8,
>>> rast_5e8a18a12ad403==4) + 78*logical_and(rast_5e8a18a12ad402==9,
>>> rast_5e8a18a12ad403==1) + 86*logical_and(rast_5e8a18a12ad402==9,
>>> rast_5e8a18a12ad403==1) + 91*logical_and(rast_5e8a18a12ad402==9,
>>> rast_5e8a18a12ad403==2) + 93*logical_and(rast_5e8a18a12ad402==9,
>>> rast_5e8a18a12ad403==3) + 72*logical_and(rast_5e8a18a12ad402==11,
>>> rast_5e8a18a12ad403==1) + 84*logical_and(rast_5e8a18a12ad402==11,
>>> rast_5e8a18a12ad403==2) + 90*logical_and(rast_5e8a18a12ad402==11,
>>> rast_5e8a18a12ad403==3) + 92*logical_and(rast_5e8a18a12ad402==11,
>>> rast_5e8a18a12ad403==4) + 45*logical_and(rast_5e8a18a12ad402==12,
>>> rast_5e8a18a12ad403==1) + 71*logical_and(rast_5e8a18a12ad402==12,
>>> rast_5e8a18a12ad403==2) + 79*logical_and(rast_5e8a18a12ad402==12,
>>> rast_5e8a18a12ad403==3) + 84*logical_and(rast_5e8a18a12ad402==12,
>>> rast_5e8a18a12ad403==4) + 50*logical_and(rast_5e8a18a12ad402==13,
>>> rast_5e8a18a12ad403==1) + 76*logical_and(rast_5e8a18a12ad402==13,
>>> rast_5e8a18a12ad403==2) + 85*logical_and(rast_5e8a18a12ad402==13,
>>> rast_5e8a18a12ad403==3) + 89*logical_and(rast_5e8a18a12ad402==13,
>>> rast_5e8a18a12ad403==4) + 75*logical_and(rast_5e8a18a12ad402==14,
>>> rast_5e8a18a12ad403==1) + 87*logical_and(rast_5e8a18a12ad402==14,
>>> rast_5e8a18a12ad403==2) + 93*logical_and(rast_5e8a18a12ad402==14,
>>> rast_5e8a18a12ad403==3) + 96*logical_and(rast_5e8a18a12ad402==14,
>>> rast_5e8a18a12ad403==4)
>>>
>>> Execution of
>>> <C:\Users\Particular\AppData\Local\Temp\processing_GWGaYw\grassdata\grass_batch_job.cmd>
>>> finished.
>>>
>>> Cleaning up temporary files...
>>>
>>> Press any key to continue . . .
>>>
>>> Starting GRASS GIS...
>>>
>>> WARNING: Concurrent mapset locking is not supported on Windows
>>>
>>> Cleaning up temporary files...
>>>
>>> Executing
>>> <C:\Users\Particular\AppData\Local\Temp\processing_GWGaYw\grassdata\grass_batch_job.cmd>
>>> ...
>>>
>>> C:\Users\Particular\Documents>chcp 1252 1>NUL
>>>
>>> C:\Users\Particular\Documents>g.region
>>> raster=outputb7f2c5ec865148f6a92bddf859fdf839
>>>
>>> ERROR: Raster map <outputb7f2c5ec865148f6a92bddf859fdf839> not found
>>>
>>> C:\Users\Particular\Documents>r.out.gdal -t -m
>>> input="outputb7f2c5ec865148f6a92bddf859fdf839"
>>> output="C:\Users\Particular\AppData\Local\Temp\processing_GWGaYw\1c703db4b0d14b2a88c0e57e10cf8d6e\output.tif"
>>> format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite
>>>
>>> ERROR: Raster map or group <outputb7f2c5ec865148f6a92bddf859fdf839> not
>>> found
>>>
>>> C:\Users\Particular\Documents>exit
>>>
>>> Execution of
>>> <C:\Users\Particular\AppData\Local\Temp\processing_GWGaYw\grassdata\grass_batch_job.cmd>
>>> finished.
>>>
>>> Cleaning up temporary files...
>>>
>>> Press any key to continue . . .
>>>
>>> Execution completed in 2.38 seconds
>>>
>>> Results:
>>>
>>> {'output': <QgsProcessingOutputLayerDefinition {'sink':TEMPORARY_OUTPUT,
>>> 'createOptions': {'fileEncoding': 'System'}}>}
>>>
>>>
>>> Loading resulting layers
>>>
>>> The following layers were not correctly
>>> generated.<ul><li>C:/Users/Particular/AppData/Local/Temp/processing_GWGaYw/1c703db4b0d14b2a88c0e57e10cf8d6e/output.tif</li></ul>You
>>> can check the 'Log Messages Panel' in QGIS main window to find more
>>> information about the execution of the algorithm.
>>>
>>>
>>> This is the GRASS log message:
>>> 2020-04-05T18:42:57 INFO processInputs end. Commands: ['g.proj
>>> -c proj4="+proj=tmerc +lat_0=39.6682583333333 +lon_0=-8.13310833333333 +k=1
>>> +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"',
>>> 'r.in.gdal input="H:\\recLUvalue.tif" band=1 output="rast_5e8a18a12ad402"
>>> --overwrite -o', 'r.in.gdal input="H:\\recSoilNu.tif" band=1
>>> output="rast_5e8a18a12ad403" --overwrite -o', 'g.region n=-59308.1937
>>> s=-78283.947 e=-38278.9651 w=-59062.1289 res=5.0']
>>>
>>> 2020-04-05T18:42:57 INFO processCommands end. Commands: ['g.proj
>>> -c proj4="+proj=tmerc +lat_0=39.6682583333333 +lon_0=-8.13310833333333 +k=1
>>> +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"',
>>> 'r.in.gdal input="H:\\recLUvalue.tif" band=1 output="rast_5e8a18a12ad402"
>>> --overwrite -o', 'r.in.gdal input="H:\\recSoilNu.tif" band=1
>>> output="rast_5e8a18a12ad403" --overwrite -o', 'g.region n=-59308.1937
>>> s=-78283.947 e=-38278.9651 w=-59062.1289 res=5.0', 'r.mapcalc.simple
>>> a=rast_5e8a18a12ad402 b=rast_5e8a18a12ad403 expression="99*(A==1) +
>>> 91*logical_and(A==2, B==1) + 94*logical_and(A==2, B==2) +
>>> 96*logical_and(A==2, B==3) + 97*logical_and(A==2, B==4) +
>>> 93*logical_and(A==3, B==1) + 95*logical_and(A==3, B==2) +
>>> 97*logical_and(A==3, B==3) + 97*logical_and(A==3, B==4) +
>>> 91*logical_and(A==4, B==1) + 94*logical_and(A==4, B==2) +
>>> 96*logical_and(A==4, B==3) + 97*logical_and(A==4, B==4) +
>>> 78*logical_and(A==5, B==1) + 86*logical_and(A==5, B==2) +
>>> 91*logical_and(A==5, B==3) + 92*logical_and(A==5, B==4) + 100*(A==1) +
>>> 79*logical_and(A==8, B==1) + 87*logical_and(A==8, B==2) +
>>> 91*logical_and(A==8, B==3) + 93*logical_and(A==8, B==4) +
>>> 78*logical_and(A==9, B==1) + 86*logical_and(A==9, B==1) +
>>> 91*logical_and(A==9, B==2) + 93*logical_and(A==9, B==3) +
>>> 72*logical_and(A==11, B==1) + 84*logical_and(A==11, B==2) +
>>> 90*logical_and(A==11, B==3) + 92*logical_and(A==11, B==4) +
>>> 45*logical_and(A==12, B==1) + 71*logical_and(A==12, B==2) +
>>> 79*logical_and(A==12, B==3) + 84*logical_and(A==12, B==4) +
>>> 50*logical_and(A==13, B==1) + 76*logical_and(A==13, B==2) +
>>> 85*logical_and(A==13, B==3) + 89*logical_and(A==13, B==4) +
>>> 75*logical_and(A==14, B==1) + 87*logical_and(A==14, B==2) +
>>> 93*logical_and(A==14, B==3) + 96*logical_and(A==14, B==4)"
>>> output=outputb7f2c5ec865148f6a92bddf859fdf839 --overwrite']
>>>
>>> Thanks in advance
>>>
>>> Cumprimentos,
>>> *Valter Albino -* Geógrafo Físico, M.Sc.
>>> Modelação H&H / Riscos ambientais / OT&U
>>> www.valteralbino.wixsite.com/hydrodynamics
>>>
>> _______________________________________________
>> grass-user mailing list
>> grass-user lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/grass-user
>
>
-------------- próxima parte ----------
Um anexo em HTML foi limpo...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20200405/961e7a88/attachment-0001.html>
More information about the grass-user
mailing list