Hello. I can not use the number pi in r.mapcalc. I tried these ways:
r.mapcalc 'prueba = pi()'
r.mapcalc 'prueba = pi'
r.mapcalc 'prueba = PI()'
r.mapcalc 'prueba = PI'
With the following results:
Syntax error
Is this normal? Is IP defined within GRASS / r.mapcalc?
Thanks for your help.
José María
José María Michia wrote:
r.mapcalc 'prueba = pi()'
r.mapcalc 'prueba = pi'
r.mapcalc 'prueba = PI()'
r.mapcalc 'prueba = PI'
With the following results:
Syntax error
Is this normal? Is IP defined within GRASS / r.mapcalc?
r.mapcalc doesn't have a definition for pi; you'll need to enter a
literal value.
Note that all of r.mapcalc's trigonometric functions accept or return
angles measured in degrees, so you don't need to explicitly multiply
or divide by pi/180.
--
Glynn Clements <glynn@gclements.plus.com>
2008/8/23 Glynn Clements <glynn@gclements.plus.com>:
r.mapcalc doesn't have a definition for pi; you'll need to enter a
literal value.
Thanks Glynn. This sounds like a weak point for me.
I need to introduce "Pi" several times. Not for converting degrees to
radians. It is another class of applications. In this case to
calculate gravity anomalies.
Is it possible to define variables? I can not find a way and I am not
convinced having to use the literal value ever need to use IP.
Thank you for your help.
Jose Maria
2008/8/23 José María Michia <jose.maria.michia@gmail.com>:
Is it possible to define variables?
2008/8/23 Glynn Clements <glynn@gclements.plus.com>:
Yes; an assignment anywhere other than at the top level will define a
variable rather than an output map. You can either place the
assignment at the point that you would first use the value, e.g.:
outmap = a * (pi = 3.14159265358979323846) + b
or use eval(), e.g.:
outmap = eval(pi = 3.14159265358979323846, a * pi + b)
Thank you, Glynn. I was able to assign the variable.
Variables remain in scope until the end of the file.
I do not know if I understood well about the scope of the variable. If
I need to use the variable in several maps, only works if Pi is
defined in each operation. For example:
This works:
r.mapcalc '= eval (pi = 3.14159265, pi + sin (map / pi))'
r.mapcalc 'b = eval (pi = 3.14159265, pi + cos (map / pi))'
But this does not:
r.mapcalc '= eval (pi = 3.14159265, pi + sin (map / pi))'
r.mapcalc 'b = eval (pi + cos (map / pi))'
Just out of curiosity: I searched on Google and documentation GRASS
how to do this, and could not find it. Does anyone know where it is
documented that?
Thanks again!
José María
PS: In response to messages from Glynn I forgot to use the address of
the group, so we forwarded those messages here. Sorry!