The attached file contains collected soil salinity samples and extracted
pixels values from Ikonos image.
I am trying to interpolate soil salinity data and use regression models
with the axillary data

I created a grid as follows:
mydata <- read.table("C:............//mydata.txt", header = TRUE)
coordinates(mydata) <- c("x", "y")
diff(sort(unique(coordinates(mydata)[,2])))
diff(sort(unique(coordinates(mydata)[,1])))
bb = bbox(mydata)
mydata.gt = GridTopology(c(bb[1,1],bb[2,1]), c(30,30),
round(c(diff(bb[1,]), diff(bb[2,]))/30) + 1)
plot(mydata)
plot(SpatialGrid(mydata.gt),col='red',add=T)
mydata.sg = SpatialGrid(mydata.gt)
fullgrid(mydata.sg)=F
mydata.grid = SpatialPixelsDataFrame(mydata.sg, data.frame(x = rep(NA,
8*15))

This above grid works fine with simple and ordinary kriging, however, I got
this error when using universal kriging or linear model:

salinity.uk <- krige(salinity~ndvi, mydata, mydata.grid, vt.fit)  #### UK

salinity.lm <- lm(salinity~ndvi, mydata)         #### LM
mydata.grid$pred <- predict(sal.lm, mydata.grid)

*Error in eval(expr, envir, enclos) : object 'ndvi' not found*

Therefore, I created another grid that contains the whole data as follows:

mydata_g <- read.table("C:............//mydata.txt", header = TRUE)
coordinates(mydata_g) <- ~ x+y
rast <- raster(ncol =8, nrow=15)
extent(rast) <- extent(mydata_g)
rasterize(mydata_g, rast, mydata_g$salinity, c(30,30), fun = mean)
gridded(mydata_g) <- TRUE









*Warning messages:1: In points2grid(points, tolerance, round) :  grid has
empty column/rows in dimension 12: In points2grid(points, tolerance, round)
:  grid topology may be corrupt in dimension 13: In points2grid(points,
tolerance, round) :  grid has empty column/rows in dimension 24: In
points2grid(points, tolerance, round) :  grid topology may be corrupt in
dimension 2*

fullgrid(mydata_g) <- F
plot(f40_g)    ### it is empty

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
list(x=c(621606,621685,621685,621606,621606),y=c(4211472,4211472,4211396,4211396,4211472))

Best Regards,
Ahmed
x       y       salinity        blue    green   red     near    ndvi
621564  4211184 3.6     505     584     501     790     0.22
621592  4211182 4       409     469     319     1025    0.53
621632  4211180 3.6     426     495     347     995     0.48
621650  4211217 4.2     415     452     317     948     0.5
621614  4211219 3.6     416     461     334     950     0.48
621569  4211222 3.1     441     492     374     838     0.38
621571  4211268 4.7     428     480     357     878     0.42
621611  4211265 6.6     417     453     319     981     0.51
621663  4211262 3.8     412     450     311     1014    0.53
621689  4211301 6.2     416     441     308     1000    0.53
621648  4211304 6.1     434     491     369     903     0.42
621608  4211307 6.4     421     482     351     912     0.44
621564  4211310 3.6     430     459     338     931     0.47
621567  4211354 4       414     451     331     923     0.47
621611  4211351 5.4     406     449     321     938     0.49
621653  4211348 7.7     453     514     417     903     0.37
621706  4211344 5.6     423     471     336     976     0.49
621739  4211387 7.4     435     501     399     874     0.37
621693  4211391 10.6    543     675     644     750     0.08
621640  4211394 10.7    463     551     463     822     0.28
621578  4211399 8.2     414     463     350     885     0.43
621564  4211446 3.2     425     474     368     841     0.39
621619  4211441 9.4     439     495     411     690     0.25
621674  4211437 9.2     464     553     482     688     0.18
621727  4211434 8       463     546     461     741     0.23
621774  4211430 4.8     435     498     400     811     0.34
621777  4211476 5.7     444     496     388     751     0.32
621717  4211480 7.2     478     566     513     607     0.08
621666  4211484 7.9     460     549     471     708     0.2
621616  4211488 5.6     417     467     348     784     0.39
621565  4211491 3.1     428     506     395     921     0.4
621624  4211534 7.8     466     541     471     717     0.21
621678  4211530 8.2     514     622     586     670     0.07
621746  4211526 8       501     580     521     609     0.08
621772  4211524 5.2     485     548     449     733     0.24
621770  4211571 3.6     503     559     460     690     0.2
621713  4211576 4.5     471     530     421     716     0.26
621662  4211579 4       475     547     468     691     0.19
621611  4211583 3.8     434     481     382     781     0.34
621566  4211586 3       486     583     491     906     0.3
621556  4211596 3.2     501     638     611     810     0.14
621612  4211592 3.7     446     490     408     722     0.28
621658  4211589 7.9     484     547     455     701     0.21
621712  4211585 5.6     471     526     417     741     0.28
621768  4211581 5.4     510     568     460     699     0.21
621771  4211527 6.5     470     535     403     810     0.34
621720  4211528 9.2     492     582     527     622     0.08
621670  4211531 11.3    497     603     554     667     0.09
621622  4211535 10.8    458     536     445     702     0.22
621569  4211538 5.3     439     481     343     924     0.46
621568  4211483 4       424     487     356     843     0.41
621620  4211479 10.1    425     478     359     796     0.38
621668  4211476 11.5    472     554     478     652     0.15
621719  4211472 10.3    485     565     497     601     0.09
621769  4211469 5       446     499     380     794     0.35
621763  4211398 3.6     425     472     364     898     0.42
621708  4211402 11.9    514     645     582     757     0.13
621660  4211406 11.3    500     597     522     809     0.22
621614  4211409 12.2    471     542     449     813     0.29
621570  4211411 8.5     438     493     392     822     0.35
621563  4211364 4.8     416     469     356     887     0.43
621612  4211360 5.7     423     462     347     887     0.44
621663  4211356 10.1    465     540     444     889     0.33
621710  4211353 7.1     456     526     405     927     0.39
621693  4211299 7.5     415     446     315     984     0.52
621650  4211302 8       427     471     341     923     0.46
621603  4211305 7.4     437     488     369     896     0.42
621572  4211308 4.5     407     445     317     963     0.5
621568  4211260 4.8     437     491     372     833     0.38
621611  4211257 5.1     419     458     322     997     0.51
621662  4211254 4.2     415     451     316     983     0.51
621650  4211208 3.7     411     447     309     950     0.51
621609  4211211 3.4     416     461     323     923     0.48
621573  4211213 3.5     427     467     341     933     0.46
621571  4211193 3.5     441     505     404     851     0.36
621610  4211190 4       432     491     363     926     0.44
621640  4211188 4.7     429     482     377     871     0.4
621628  4211173 4.6     409     452     302     1137    0.58
621599  4211176 3.8     415     463     320     1016    0.52
621565  4211177 4.2     552     688     657     772     0.08
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to