Skip to content
Prev 23313 / 29559 Next

How to use coKriging with LANDSAT ETM Imagery

Please find a working script below. The error message was given because
the variable "value" was not present in new.data; the variable was
called "Sample1_Band3".

It is quite unclear what you try to do: interpolating an image at the
image pixels themselves (which will, by definition, return the original
image), in any case, there is no cokriging going on in this script.



library(raster)
library(sp)
library(rgdal)
library(gstat)
library(rasterVis)
library(lattice)

#sink(file="/home/raj/evolution_research/Geocomputing/coKriging/bands345_run.log")

Image1 <-raster("Sample1_Band3.tif", layer=1, values="TRUE")
Image1

r1 <- readGDAL("Sample1_Band3.tif")
image(r1)

rGrid <- as(r1, "SpatialPixelsDataFrame")
summary(rGrid)

new.data <- as(Image1, "SpatialPointsDataFrame")

coKrige <- gstat(formula=Sample1_Band3 ~ 1, data=new.data, nmax = 10)
# I'm setting nmax to avoid absurd long computation

coKrige2 <- gstat(g=coKrige, model=vgm(1, "Gau", 350, 1), fill.all=TRUE)
list(coKrige2)

coKrige1 <- variogram(coKrige2)

class(coKrige1) <- c("gstatVariogram", "data.frame")
coKrige1$np <- rep(15, nrow(coKrige1))
coKrige1

coKrige.fit <- fit.lmc(coKrige1, coKrige2, vgm(1, "Gau", 350, 1), TRUE, 1.0)
coKrige.fit

plot(coKrige1, model=coKrige.fit$model[[1]])

coKrige.predict <- predict(coKrige.fit, rGrid, nmax = 5, debug.level = -1)
spplot(coKrige.predict[1])

#plot(coKrige.predict)
On 08/29/2015 10:33 PM, Rajabhushanam. C wrote: