[Qgis-user] how to fix the raster calculator

Áron Gergely aron.gergely at rasterra.nl
Tue Sep 24 04:00:56 PDT 2019


Hi Raymond and list,

I think your first issue may have been caused by the decimal character 
in your formula not matching the locale;
Can be a point '.' or comma ','

I also use the 'high school math' methods you mentioned ;) I am not 
aware of any tricks.
Would be nice to have convenience functions for abs(), max(), mean(), 
stdev(), etc..

As a workaround you can use the GDAL raster calculator, I think abs() 
and similar are implemented there.

If anyone is aware of any QGIS raster calculator tricks I would be eager 
to learn about them as well.

Best Regards,
Aron

On 24/09/2019 12:19, Raymond Nijssen wrote:
> Hi,
>
> I've been using the raster calculator lately and bumped into some 
> unexpected behaviour issues. They are hard to isolate but I will 
> create issues
>
> One of the things is the creation of empty output grids, resulting in 
> raster layers with a range as described earlier in this thread:
>
> ([-1.79769e+308 to 1.79769e+308] instead of [0 1].
>
> Somehow this was fixed after changing the locale (!) from NL back to 
> EN. I was using a model that contained raster calculators and a python 
> script running it.
> No clue what it could be, maybe parameter names being translated (I 
> hope not!) or locale settings for decimal point/comma.
>
> Also, the names of the model parameter are like 
> 'qgis:rastercalculator_4:sub_calc_sqrt', still containing the 
> 'rastercalculator_4' part which can not be found or changed using the 
> model editor.
>
>
> Besides, I'm wondering why very common functionality is missing in the 
> raster calculator. I need abs() and max() functions and they don't 
> exist. Or am I missing something?
>
> My solutions / work arounds using creative high school math are:
>
> abs(a):
> sqrt(a * a)
> or
> ((a >= 0) * a) + ((a < 0) * -1 * a)
>
> max(a, b):
> ((a >= b) * a) + ((a < b) * b)
>
>
> Hope someone has a clue here. Guess I'm not the only one using vector 
> more often than raster...
>
> Kind regards,
> Raymond
>
>
>
> On 21-03-19 17:19, shalum HOUENOU wrote:
>> OK then
>>
>> Maixent,
>>
>> *De : *matteo <mailto:matteo.ghetta at gmail.com>
>> *Envoyé le :*jeudi 21 mars 2019 17:14
>> *À : *shalum HOUENOU <mailto:shalumhouenou at gmail.com>
>> *Objet :*Re: [Qgis-user] how to fix the raster calculator
>>
>> please answer to all (so you question is forwarded also to the user
>>
>> mailing list)
>>
>> I think then the raster calculator has a bug. Could you please report 
>> it?
>>
>> https://issues.qgis.org/projects/qgis
>>
>> or try to upgrade to QGIS 3.6
>>
>> On 3/21/19 5:13 PM, shalum HOUENOU wrote:
>>
>>  >
>>
>>  >
>>
>>  > Yes I did, as it was mentionned in the training manual, section 8.3.7
>>
>>  >
>>
>>  > You have the link below :
>>
>>  >
>>
>>  > 
>> https://docs.qgis.org/testing/en/docs/training_manual/rasters/terrain_analysis.html#moderate-fa-using-the-raster-calculator
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  > Maixent,
>>
>>  >
>>
>>  > *De : *matteo <mailto:matteo.ghetta at gmail.com>
>>
>>  > *Envoyé le :*jeudi 21 mars 2019 17:07
>>
>>  > *À : *shalum HOUENOU <mailto:shalumhouenou at gmail.com>;
>>
>>  > qgis-it-user-owner at lists.osgeo.org
>>
>>  > <mailto:qgis-it-user-owner at lists.osgeo.org>
>>
>>  > *Objet :*Re: [Qgis-user] how to fix the raster calculator
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  > Hi Maixent,
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  >> Indeed the boundaries of my output layer have Strange values
>>
>>  >
>>
>>  >> ([-1.79769e+308 to 1.79769e+308] instead of [0 1].
>>
>>  >
>>
>>  >>
>>
>>  >
>>
>>  >> Thus the output layer is invisible.
>>
>>  >
>>
>>  >>
>>
>>  >
>>
>>  >> I’ve already tried to change the max and the min value : The 
>> layer is
>>
>>  >
>>
>>  >> still invisible.
>>
>>  >
>>
>>  >>
>>
>>  >
>>
>>  >> What else could I do to fix it ? Any idea ?
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  > did you also set the reference layer in the algorithm UI?
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>  > Matteo
>>
>>  >
>>
>>  >
>>
>>  >
>>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list