[STATSGRASS] spatial interpolation of rain data with few points

javier garcia - CEBAS rn001 at cebas.csic.es
Mon Nov 10 05:02:21 EST 2003


Hi all,

First of all, thanks all for your answer to a previous question 
(options(digits=n) is what I needed), and Roger B. for the description of 
interpolation posibilities.

But, about interpolation, I am having problems to get maps from a few data 
points. 
I've got just four points representing rain gauged in four stations.
I've tried to interpolate the values with the wrapper function interp.new.G, 
in library(GRASS) of R, but there is an error because it seem that the 
minimum number of points should be 9.
In the help I've found that the minimum is 4, not 9. (?):

-----------------
*** SDSF3P Error 1: NDP = 9 or less
    MD =    1,  NDP =    4
-----------------

Could I change this minimum?

In other way, I've tried to use another algorithm, to fit a trend surface by 
least-squares, with library(spatial) and the function surf.ls.
But there is also an errror (?):
-------------------------
> rainstations.s
         east       north             id      str2                 
1 664304.8935 4227048.780  1   est7237              
2 666504.8166 4215899.535  2   est7238  
3 667467.0677 4217707.843  3   est7239 
4 671555.4027 4230683.611  4   est7250 
> rain.tss
Time Series:
Start = 1
End = 10
Frequency = 1
   est7237 est7238 est7239 est7250
 1       0       0       0       0
 2       0       0       0       0
 3       0       0      17       0
 4      47     103      78      73
 5       0       0       0       0
 6      35      40      34      82
>library(spatial)
>rain.kr <- as.list(x <- 0)
>rain.maps <- as.list(x <- 0)
> G$xlim
[1] 651700 679700
> G$ylim
[1] 4214100 4242100
> G$Nrow
[1] 280
>for (i in 1:end(rain.tss)[1]){
rain.kr[[i]] <- 
surf.ls(2,rainstations.s$east,rainstations.s$north,rain.tss[i,])
rain.maps[[i]] <- 
trmat(rain.kr[[i]],G$xlim[1],G$xlim[2],G$ylim[1],G$ylim[2],G$Nrow)
}

The answer to this is:
Error in .trval(object, x, y) : NA/NaN/Inf in foreign function call (arg 5)
----------------------------------
I've also tried to find out the source of this error, but I can't find it. 
Perhaps also the limited number of points?

I guess you have realized I'm pretty new with R. In any case. I'm stuck here.
I must say that I've been able to resolve this, at last, sending the points 
to GRASS and making the interpolation with s.to.rast, and although there are 
some warning, I think that the result is satisfactory:
------------------------
>sites.put2(G,data=rain.tss.temp,lname=paste("rain.map",i,sep=""),dims=c("east","north"),check=FALSE)
>system(paste("s.surf.rst input=rain.map",i," maskmap=MASK npmin=4 segmax=8 
elev=rain.map.temp",i,sep=""))
>system(paste("r.mapcalc 'rain.map",i," = 
if(rain.map.temp",i,"<0,0,rain.map.temp",i,")'",sep=""))
system(paste("g.remove rast=rain.map.temp",i,sep=""))
------------------------------------------------------------
But as I haen't got much expertise in this field, I'm not sure if this is a 
good method for this, nor can find out how to resolve the problems in R.
 
Could any of you, please, advise me about what method, included in R, could I 
use with these little amount of points,
or give me any hint about the source of these errors?

Perhaps you know any references about analysis of rain event ? (I have time 
series in four rain stations and perhaps there is some method to analyse, not 
only spatial interpolation for every timestep, but also the movement or the 
rain event considering the position of rain stations and desplacement in time 
series) 

Any answer to any of the questions will be very good for me.

Thanks all, and best wishes

Javier Garcia




More information about the grass-stats mailing list