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

Mauricio Zambrano hzambran.newsgroups at gmail.com
Fri Apr 1 09:59:18 CEST 2011


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.

-- 
=======================================================
FLOODS Action
Land Management and Natural Hazards Unit
Institute for Environment and Sustainability
European Commission, Joint Research Centre
=======================================================
DISCLAIMER:\ "The views expressed are purely those of th...{{dropped:11}}



More information about the R-sig-Geo mailing list