[R-sig-Geo] RE : grid error for kriging

Tobin Cara cara.tobin at epfl.ch
Mon Nov 9 15:27:03 CET 2009


Dear Roger,

My Prec00 is a data frame as I imported it as a matrix from a text file. It has 32 rows (one for each precipitation station) and 72 columns (72 hours of data at each station). I interpolated by importing a second matrix with just the X, Y, and Z of the original data and iterated for each column. I had no problem doing this when I used a simpler grid (data_v) with more X, Y and Z values, imported as a text file(not a spatial DTM).

list_ked <- vector("list",72)
 
for(i in 1:72){
 list_ked[[i]] <- krige(Prec00[,i]~Z, locations=DataCoord, newdata=data_v, model = fitted_vario)
}

My successful KED code without iterating with the DTM 'elev' (where I used the mean of Prec00 over 72 hours) was:

elev_ked <- krige(meanPrec~Z, meanPrec, newdata=elev, fitted_vario)

The difference in the data frame for the mean is I have the X, Y, and Z associated with each meanPrec value at each station in the same matrix (32 rows by 4 cols: X, Y, Z, meanPrec).

So, when mixing a spatial data frame 'elev' with 2 matrices defining the original data, there seems to be a problem. Calling Prec00 gives me only the precipitation for a time step because its a separate matrix from the coordinates.

Any ideas?

Cheers

________________________________________
De : Roger Bivand [Roger.Bivand at nhh.no]
Date d'envoi : lundi, 9. novembre 2009 12:27
À : Tobin Cara
Cc : r-sig-geo at stat.math.ethz.ch
Objet : Re: [R-sig-Geo] grid error for kriging

On Mon, 9 Nov 2009, Tobin Cara wrote:

> Hello,
>
> Has anyone ever used a DTM as their grid for interpolation and come
> across this error. My DTM has pixels 100 m by 100 m, so I really do not
> understand this error as it is regular. Also, this only happens when I
> am doing multiple iterations in time.
>
>
>
> Code:
> list_ked[[i]] <- krige(Prec00[,i]~Zloc, locations=DataCoord, newdata=elev, model = fitted_vario)
> [using universal kriging]
>

Please do check the arguments to the formula carefully. If Prec00 is a
SpatialGridDataFrame, you are not asking for it's i'th variable here. It's
a design decision that you need Prec00[,,i] to get the variable, or get it
by name:

library(sp)
data(meuse.grid)
coordinates(meuse.grid) <- c("x", "y")
str(meuse.grid[,1])
gridded(meuse.grid) <- TRUE
str(meuse.grid[,1])
fullgrid(meuse.grid) <- TRUE
str(meuse.grid[,1])
str(meuse.grid[,,1])

Maybe helping some users to subset by row and column has removed the
otherwise prevalent semantic link to data.frame objects, and maybe this
(tricky) side of the "[" operator on SpatialGridDataFrame objects should
be reversed?

Roger

>
>
> Error:
> suggested tolerance minimum: 0.25
> Error in points2grid(points, tolerance, round, fuzz.tol) :
> dimension 1 : coordinate intervals are not constant
>
>
> I can rescale the DTM to be less refined (now it is 100 m2 for a 6,000
> km2 area) if needed.
>
> Thank you again,
>
> Cara
>
>
>
>
>
>
>       [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list