[GRASS-dev] scientific notation in r.mapcalc ?

Moritz Lennert mlennert at club.worldonline.be
Fri Jun 16 08:41:24 PDT 2017


Hi Glynn !

On 16/06/17 02:35, Glynn Clements wrote:
>
> Markus Neteler wrote:
>
>>> I just stumbled upon this while running a large model, and noticed that I
>>> couldn't easily find an answer:
>>>
>>> IIUC r.mapcalc does not support scientific notation of floating point
>>> numbers (i.e. 2.540000e-05 instead of 0.0000254). Is that correct ?
>>>
>>> How difficult would it be to implement the support of such notation ?
>>
>> We just stumbled over the same issue... would be nice to have.
>
> It works here:
>
> 	$ r.mapcalc "foo = 2.540000e-05"
> 	$ r.info -r foo
> 	min=2.54e-05
> 	max=2.54e-05

I can confirm that this works here as well. I have to admit that I don't 
remember the details, but it was in the context of a python script, so 
maybe it was something in the script. And I can't remember what solution 
I found at the time.

It also works in python:

import grass.script as g
a = 2.54e-11
mce = "test = %e" % a
g.run_command('r.mapcalc', expre=mce, overwrite=True)
g.parse_command('r.info', flags='r', map_='test')
{u'max': u'2.54e-11', u'min': u'2.54e-11'}

Markus, what was your recent issue ? Maybe that will ring a bell for me...

[...]

>
> Is this issue a wxGUI thing?
>

I wasn't confronted with it using the GUI, but running a script, AFAIR.

Moritz


More information about the grass-dev mailing list