[R-sig-Geo] gstat::krige: different spatial extent of 'newdata' and kriged object

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Apr 4 12:38:21 CEST 2011


Thanks for the clear report Mauricio - very helpful. Package gstat
version 0.9-80, now submitted to CRAN, should resolve this.

With best regards,

On 04/01/2011 09:59 AM, Mauricio Zambrano wrote:
> Dear list,
> 
> While using the 'krige' function of gstat, I realised that -in some
> cases- the spatial extent of the object obtained with the 'krige'
> function is different from the spatial extent of the object provided
> as 'newdata' argument to the function.
> 
> In particular this occurred when the map passed as 'new data' argument
> ('SpatialGridDataFrame' object, read with readGDAL) had some empty
> rows in the upper part of the map.
> 
> Below there is a reproducible example (R version 2.12.2 and gstat_0.9-79 ):
> 
> 
> ----------------- START --------------------
> library(gstat)
> 
> data(meuse)
> coordinates(meuse) = ~x+y
> 
> data(meuse.grid)
> 
> # Removing unnecessary bands
> meuse.grid$part.a <- NULL
> meuse.grid$part.b <- NULL
> meuse.grid$dist <- NULL
> meuse.grid$ffreq <- NULL
> gridded(meuse.grid) = ~x+y
> 
> # Getting the class of 'meuse.grid' (SpatialPixelsDataFrame)
> class(meuse.grid)
> #"SpatialPixelsDataFrame"
> 
> summary(meuse.grid)
> #nrows=104
> #ncols=78
> 
> # B) Transforming 'meuse.grid' from 'SpatialPixelsDataFrame' to
> 'SpatialGridDataFrame'
> meuse.grid <- as(meuse.grid,'SpatialGridDataFrame')
> 
> # Variogram
> m <- vgm(.59, "Sph", 874, .04)
> 
> x1 <- krige(log(zinc)~1, locations=meuse, newdata=meuse.grid, model = m)
> summary(x1)
> #nrows=104
> #ncols=78
> 
> # In this example, the resulting object 'x1' has the same amount of
> rows and column of 'meuse.grid'
> 
> ###################################
> # Putting some NA's in 'meuse.grid'
> meuse.grid at data[1:156,] <- NA
> summary(meuse.grid)
> #nrows=104
> #ncols=78
> 
> x2 <- krige(log(zinc)~1, locations=meuse, newdata=meuse.grid, model = m)
> summary(x2)
> #nrows=102
> #ncols=78
> 
> ----------------- END --------------------
> 
> In the latest example, why 'x2' has 102 rows if 'meuse.grid' has 104 ?
> 
> 
> Thanks in advance for any help,
> 
> Mauricio Zambrano B.
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list