1

I am new to R for GIS and I am trying to get universal kriging working in Autokrige in R but I am running into problems. Ordinary kriging works with my dataset so I think the problem is to do with the predictor grid which is an ASC file. The data I used is here. https://www.dropbox.com/sh/lkg8qtp2eowmml8/AABWYWegF-FgsbIT1i-5y6VEa?dl=0

library(sp)
xdata <- read.table(file="C:\\Users\\Robert\\Dropbox\\Dplaces.txt",header=TRUE,na.strings = "NA", sep="\t")

p <- xdata                                              
p$g <- p$Asin.gather
coordinates(p) <- ~ x + y

##Set the coordinate system
proj4string(p) <-CRS("+proj=utm +zone=10 +datum=WGS84")                                              

##Load first temperature GeoTiff raser  from worldclim 
library(raster)
f <- "C:\\Users\\Robert\\Documents\\QGIS Database\\bcmidbi_10m\\bcmidbi11.tif"
       r <- raster(f)
bcmidbi11  <- aggregate(r, fact=2)  ## By default aggregates using mean, but    see fun=

##Load second temperature GeoTiff raser from worldclim 
       f <- "C:\\Users\\Robert\\Documents\\QGIS Database\\bcmidbi_10m\\bcmidbi10.tif"
       r <- raster(f)
bcmidbi10  <- aggregate(r, fact=2)  ## By default aggregates using mean, but see fun=

   ##calculate global effective temperature from rasters which is my predicator variable 
x <- bcmidbi11  /100
y <- bcmidbi10  /100
a <-   18*y
b <-   x  
c <-   y-x
d <-   c+8
e <-   a-b
MET_map <-   e-d
MET<-read.asciigrid("org_matter.asc")
proj4string(MET) <-CRS("+proj=utm +zone=10 +datum=WGS84")


ra <- aggregate(MET_map, fact=2)  ## By default aggregates using mean, but see fun=
writeRaster(ra, "C:\\Users\\Robert\\Documents\\outfile.asc", format="ascii")

Error in .startAsciiWriting(x, filename, ...) : 
x has unequal horizontal and vertical resolutions. Such data cannot be stored in arc-ascii format

When this I run into some conversion problem. I tried to experimentally continue with the Meuse dataset, using the Meuse 's data set dist to continue.

x.range <- as.numeric(c(-169.00, 172.00))  # min/max longitude of the interpolation area
y.range <- as.numeric(c(-53.00, 79.00))  # min/max latitude of the interpolation area
grd <- expand.grid(x = seq(from = x.range[1], to = x.range[2], by = 0.1), y = seq(from = y.range[1], 
to = y.range[2], by = 0.1))  # expand points to grid, from dataframe to spatialpixels

coordinates(grd) = ~x+y        # from dataframe to SpatialGrid

library(automap)
kriging_result = autoKrige(g~dist, p, new_data=grd)

Error in model.frame.default(terms(formula), as(data, "data.frame"), na.action = na.fail): invalid type (S4) for variable 'dist'

Have you any idea what the problem is?

I have tried kriding in other packages and I have had similar problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.