[R-sig-Geo] RSAGA, Bayes' Theorem and summary stats

Alexander Brenning brenning at uwaterloo.ca
Wed Sep 30 23:00:45 CEST 2009

Hi Steve,

I recommend checking the data type of all involved rasters in SAGA GIS (GUI) itself, maybe one of the grids involved is integer so everything gets rounded to zero? After loading a grid into SAGA GIS, select it in the 'Data' tab of the 'Workspace' window, and examine the 'Description' in the 'Object Properties' window. There's a 'Value Type' attribute, which should be FLOAT.
If mixed data types (float, integer) are involved in your grid calculus call, changing the order may help.

Also, try splitting the formula into several calls to be able to track intermediate results. And if things are still puzzling, do some simple operations to really see what's going on.

And finally, the SAGA forum on SourceForge may provide help on SAGA GIS (there's also a bug tracker, in case this is a bug).

I hope this helps

Steven Van Wilgenburg wrote:
> Hi.
> I am attempting to create a method to forensically assign migratory
> birds to their geographic origins (on a GIS layer from
> http://wateriso.eas.purdue.edu/waterisotopes/pages/data_access/ArcGrids.html)
> based on stable-istope analyses of the feathers.
> I am trying to use Bayes' Theorem to assign birds, one at a time to
> the aforementioned surface (after calibration of the surface into
> values expected for bird feathers). I am having some success with the
> following script.....
> #####ASSIGN BIRDS using Bayes' Theorem for a Normal Probability
> density################################## birds<- c(-121.07,-112.56) SD<-12.56587 for (i in 1:length(birds)){ rsaga.grid.calculus(in.grids
> = c("wtspddf.sgrd"), out.grid =
> paste("wtspassignment",i,".sgrd",sep=""), formula =
> paste("(1/(sqrt(2*",pi,")*",SD,"))*exp(-(1/(2*(",SD,")2))","*(",birds[i],"-a)2)",sep=""))
>  }
> However, I wish to multiply this with another surface representing
> prior probabilities, but the results from the above script have so
> many decimal places (e.g. max 0.03141 min 0.000006)  that  applying
> the prior probabilities appears to exceed the number of digits
> allowed for a grid, resulting in all zeros). I want to normalize the
> above by dividing by the maximum value of the result, but see no way
> to calculate the maximum value for a surface. Does anyone know of a
> way I could do this? Or is it possible to reset the number of digits?
> I suppose that ther disadvantage to changing the number of digits
> would expand the file sizes enormously....
> I suppose I could also consider multiplying by an arbitrary amount
> first (before applying priors) as an alternative, but wanted to
> normalize by dividing by max. Suggestions would be most appreciated.
> Cheers
> -Steve

More information about the R-sig-Geo mailing list