<div dir="ltr"><div><div><div>The attached file contains collected soil salinity samples and extracted pixels values from Ikonos image.<br>I am trying to interpolate soil salinity data and use regression models with the axillary data<br>
<br>I created a grid as follows: <br>mydata <- read.table("C:............//mydata.txt", header = TRUE)<br>coordinates(mydata) <- c("x", "y")<br>diff(sort(unique(coordinates(mydata)[,2])))<br>
diff(sort(unique(coordinates(mydata)[,1])))<br>bb = bbox(mydata)<br><a href="http://mydata.gt">mydata.gt</a> = GridTopology(c(bb[1,1],bb[2,1]), c(30,30), round(c(diff(bb[1,]), diff(bb[2,]))/30) + 1)<br>plot(mydata)<br>plot(SpatialGrid(<a href="http://mydata.gt">mydata.gt</a>),col='red',add=T)<br>
<a href="http://mydata.sg">mydata.sg</a> = SpatialGrid(<a href="http://mydata.gt">mydata.gt</a>)<br>fullgrid(<a href="http://mydata.sg">mydata.sg</a>)=F<br>mydata.grid = SpatialPixelsDataFrame(<a href="http://mydata.sg">mydata.sg</a>, data.frame(x = rep(NA, 8*15))<br>
<br>This above grid works fine with simple and ordinary kriging, however, I got this error when using universal kriging or linear model:<br><br><a href="http://salinity.uk">salinity.uk</a> <- krige(salinity~ndvi, mydata, mydata.grid, vt.fit) #### UK<br>
<br>salinity.lm <- lm(salinity~ndvi, mydata) #### LM<br>mydata.grid$pred <- predict(sal.lm, mydata.grid)<br><br><i>Error in eval(expr, envir, enclos) : object 'ndvi' not found</i><br><br>Therefore, I created another grid that contains the whole data as follows:<br>
<br>mydata_g <- read.table("C:............//mydata.txt", header = TRUE)<br>coordinates(mydata_g) <- ~ x+y<br>rast <- raster(ncol =8, nrow=15)<br>extent(rast) <- extent(mydata_g)<br>rasterize(mydata_g, rast, mydata_g$salinity, c(30,30), fun = mean)<br>
gridded(mydata_g) <- TRUE<br><br><i>Warning messages:<br>1: In points2grid(points, tolerance, round) :<br> grid has empty column/rows in dimension 1<br>2: In points2grid(points, tolerance, round) :<br> grid topology may be corrupt in dimension 1<br>
3: In points2grid(points, tolerance, round) :<br> grid has empty column/rows in dimension 2<br>4: In points2grid(points, tolerance, round) :<br> grid topology may be corrupt in dimension 2</i><br><br>fullgrid(mydata_g) <- F<br>
plot(f40_g) ### it is empty<br><br></div>I would appreciate if someone could help me how to create a grid that contains the rest of columns beside x and y coordinates and also displays only the shape of the field which has the following coordinates<br>
list(x=c(621606,621685,621685,621606,621606),y=c(4211472,4211472,4211396,4211396,4211472))<br><br></div>Best Regards,<br></div>Ahmed<br></div>