[R-sig-Geo] How to use coKriging with LANDSAT ETM Imagery

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Aug 31 13:28:29 CEST 2015


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:
> Hi,
> 
> I am using a Landsat ETM Scene imagery for calculating the Linear
> Corregionalization Method in CoKriging.  (gstat).
> 
> Can you kindly debug my snippet (See enclosed). Really appreciate your
> help.
> 
> 
> Thanking in advance.
> 
> 
>> coKrige1 <- variogram(coKrige2) Error in
> model.frame.default(terms(formula), as(data, "data.frame"), na.action =
> na.fail) : object is not a matrix
> 
> 
>> coKrige.fit <- fit.lmc(coKrige1, coKrige2, vgm(1, "Gau", 350, 1), TRUE,
> 1.0) Error in fit.lmc(coKrige1, coKrige2, vgm(1, "Gau", 350, 1), TRUE,
> 1) : gstatVariogram var1 not present
> 
> 
>> coKrige.predict <- predict(coKrige.fit, rGrid) Error in
> UseMethod("predict") : no applicable method for 'predict' applied to an
> object of class "c('variogramModel', 'data.frame')"
> 
> 
> 
> 
> On Fri, Aug 21, 2015 at 3:33 PM, Rajabhushanam. C <rajcheruk at gmail.com
> <mailto:rajcheruk at gmail.com>> wrote:
> 
>     Hi,
> 
>     I am using a Landsat ETM Scene imagery for calculating the Linear
>     Corregionalization Method in CoKriging.  (gstat).
> 
>     Specifically, there is one raster band imagery and then using
>     readGDAL and gstat function calls, I am making a gstat object that
>     is input to the Variogram call. Now, while I use *fit.lmc()*, I get
>     an error message *"gstatVariogram var1 not present"*. I have done
>     some preliminary findings, and there are no pertinent messages in
>     this message board that have Raster as an input to cokriging.
> 
>     Really appreciate if anybody can point me some relevant code or
>     pseudo code to perform cokriging with Landsat one band imagery.
> 
>     Thank You
>     C. Rajabhushanam.
> 
> 
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi),  University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20150831/02e656c9/attachment.bin>


More information about the R-sig-Geo mailing list