[GRASS-user] log(0)-error in r.mapcalculator

Markus Metz markus.metz.giswork at gmail.com
Fri Nov 9 01:22:36 PST 2012


On Fri, Nov 9, 2012 at 9:27 AM, Patrick S. <patrick_GIS at gmx.ch> wrote:
> Thank you so much, Markus!
>
> That was the missing hint and it works now!
> However, I just went through the documentation, which says: "F means that
> the functions always results in a floating point value" and Function "log"
> has "F".

The documentation is correct. The problem arose because
((A/100)/(1-(A/100)) returns an integer value if A is an integer, i.e.
the truncation happened before log() is called.

Markus M

>
>
>
>  that On 11/08/2012 07:34 PM, Markus Metz wrote:
>
> On Thu, Nov 8, 2012 at 10:50 AM, Patrick S. <patrick_GIS at gmx.ch> wrote:
>
> Dear List,
>
> I keep getting a log(0) error in r.mapcalculator, even if I enlarge the
> data. This seems to be a bug as I controlled the same data with R and get
> (non-infinity) values. Does r.mapcalculator eventually truncate the results
> of formulas to some integer values?
>
> logit-expression:  log(((A/100)/(1-(A/100)))
>
> In r.mapcalc, the numbers are treated as integers. Try instead log(((A
> / 100.0) / (1.0 - (A / 100.0)))
> Changing e.g. 1 to 1.0 forces r.mapcalc to do floating point calculations.
>
> HTH,
>
> Markus M
>
>
> To avoid error of log(0) I enlarged the data by 0.00001, 1 and 5 but keep
> getting the error.
>
> I run it out of R with:
> param<-list(amap="r_slope_perc", formula="log(((A+0.00001)/100)/(1-(A/100)))
> ", outfile="r_slope_perc_logit")
> execGRASS("r.mapcalculator", parameters=param, flags=c("overwrite"))
>
> (r.mapcalculator amap="r_slope_perc",
> formula="log(((A+0.00001)/100)/(1-(A/100)))" outfile="r_slope_perc_logit"
> --overwrite)
>
>
> Any ideas why this happens?
>
> Patrick
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>


More information about the grass-user mailing list