Dear Moshood,

On 07-Aug-13 22:45, Moshood Agba Bakare wrote:
> Dear Jon,
> Thanks for suggesting kriging in local neighborhood. I used 10 nearest 
> neighbors for interpolation and I got the result with few minutes. For 
> better understanding of what I am doing, please I need more 
> clarification on the questions below based on the output that follows:
> 1) The yield monitor data is from irregular grid pattern. Is it right 
> to interpolate on regular grid by defining my grid cell to be 20 x 20? 
> Is there any criteria for choosing the cell size? That is, what is the 
> basis for determine the grid cell size for interpolation? I just chose 
> 20m x 20m.

The optimum cell size depends on what you want to use the result for, 
and the average distance between your current observations. When writing 
cell size, do you mean that you want to predict the yield for the 20*20 
m grid cell, or you want to make a prediction on points on a grid with 
20 m resolution?

>  2) Is it possible to interpolate on irregular grid? If yes, please 
> give me the tips or guide.
krige can interpolate to basically any kind of spatial structure. By 
irregular grid, do you mean a grid which is not fullgrid, or a grid that 
is not regular in the projection you are using? In the first case you 
can use SpatialPixels, whereas you can use SpatialPoints in the second case.
> 3) The summary below shows that my *grid object (grd.pts) *belongs to 
> class SpatialPixels and not SpatialPixelsDataFrame. Hope this is right 
> for not being in the same class as the *krige object (k10)* which is 
> SpatialPixelsDataFrame.
Yes, as long as you do not want to do any kriging with covariates, such 
as cokriging, universal kriging, regression kriging. A 
SpatialPixelDataFrame is a SpatialPixels with variable values or results 
for all the pixels in the object.

> 4) My interpolation grid shows *1280* spatial points. Does it mean the 
> interpolation is restricted to those 1280 points and not to the entire 
> 12,235 spatial points from the originial spatial data?
It means you have interpolated to those 1280 points.
When you interpolate from a large number of points to a lower number of 
points, it sounds like you are interested in block estimates for your 
grid, i.e., to predict the yield from a block. You can do this either by 
setting the block-argument to krige, or by interpolating to a 
SpatialPolygons object. This will particularly affect the prediction 
error (var1.var) which  will be lower, but also the predictions.
> 5) Am I right to have defined the  coordinate reference system (CRS) 
> i.e. UTM for my grid which is the same with that of spatial data?
Yes.
> 6) The summary of  krige object *(k10)* gave the statistics of 
>  predicted yield and variance across the 1280 points within the 
> interpolation grid. Right? What other statistics or output can also be 
> derived from this object?

Those are the most important. You could also consider cross-validation 
(krige.cv) to see how well your model actually works for the point 
predictions.

> I think the response to above questions will help me to understand 
> better what I am doing. Thanks while looking forward to reading from you.

I hope this helps you a bit further, but I would also recommend you to 
read a text book on the subject. The book "Applied Spatial Data Analysis 
with R" by Bivand, Pebesma and Gomez-Rubio will give you a brief 
description on geostatistical methods and also how to do this with R.

Best regards,
Jon

> >summary(grd.pts)
> Object of class SpatialPixels
> Coordinates:
>               min     max
> easting   320936  321736
> northing 5708116 5708756
> Is projected: TRUE
> proj4string :
> *[+proj=utm +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0]
> *Number of points:*1280
> *Grid attributes:
>           cellcentre.offset cellsize cells.dim
> easting             320946       20        40
> northing           5708126       20        32
> *k10 <- krige(yield ~ 1, canmod.sp, newdata = grd.pts, model=sph.mod, 
> nmax = 10)*
> >summary(k10)
> Object of class SpatialPixelsDataFrame
> Coordinates:
>               min     max
> easting   320946  321726
> northing 5708126 5708746
> Is projected: TRUE
> proj4string :
> [+proj=utm +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0]
> Number of points: 1280
> Grid attributes:
>           cellcentre.offset cellsize cells.dim
> easting             320946       20        40
> northing           5708126       20        32
> Data attributes:
>     var1.pred         var1.var
>   Min.   : 44.41   Min.   :118.7
>   1st Qu.: 95.95   1st Qu.:127.4
>   Median :104.50   Median :128.5
>   Mean   :102.98   Mean   :151.4
>   3rd Qu.:111.24   3rd Qu.:131.2
>   Max.   :131.27   Max.   :320.9
> Best regards
> Moshood
>
>
> On Wed, Aug 7, 2013 at 3:49 AM, Jon Olav Skoien 
> <jon.skoien@jrc.ec.europa.eu <mailto:jon.skoien@jrc.ec.europa.eu>> wrote:
>
>     On 06-Aug-13 21:41, Moshood Agba Bakare wrote:
>
>         Dear All,
>
>         I have carried out variogram analysis on geostatistical data
>         using gstat
>         package of R. after rescaling my spatial coordinates, it
>         ranges as follows
>         easting: min=0 and max=794.256 meters
>         northing: min= and max=621.8851 meters
>         the maximum distance between pairs of observation is 1008.754
>         meters.
>         I have fitted a number of variogram models such as spherical,
>         exponential,
>         Gaussian, and linear to empirical semivariogram. Besides, I
>         have generated
>         the interpolation grid for kriging. With this information, I
>         wish to
>         determine optimal grid size and interpolate with kriging. The
>         cross
>         validation will be used to compare the values.
>
>         ### Create grid for the point coordinate
>
>         easting.range <- as.integer(range(canmod.sp@coords[,1]))
>         northing.range <- as.integer(range(canmod.sp@coords[,2]))
>
>         ## now expand to a grid with 10 meter spacing:
>         grd <- expand.grid(x = seq(from=easting.range[1], to =
>         easting.range[2], by
>         = 10), y = seq(from = northing.range[1], to =
>         northing.range[2], by = 50) )
>         grd.attr = data.frame(grd, yield = canmod.sp@data)
>
>         ## convert to SpatialPixel class
>         grd.pts <- SpatialPixels(SpatialPoints(grd))
>         proj4string(grd.pts)<-CRS("+proj = utm + datum = WGS84")
>
>
>         k10 <- krige(yield ~ 1, canmod.sp, newdata = grd.pts,
>         model=sph.mod)
>
>
>         I ran the last statement for kriging interpolation but take
>         quite a long
>         time with error message. This is probably due to large volume
>         of the data
>         records (12,800 observations). Could anyone guide me on what
>         to do when
>         having large data of this nature for kriging? Is there any
>         error on the way
>         I defined my grid interpolation? Do I need to split the data
>         for kirging?
>         If yes, how?
>
>
>     Moshood,
>     We have not seen the error message, but I think the size of your
>     data is the cause of your problems. gstat will as default try to
>     make a covariance matrix of all observations, being a 12,800 *
>     12,800 matrix in your case. This is slow and will maybe also fill
>     up the memory on your computer. Instead you can do kriging in a
>     local neighbourhood with the nearest n observations, n typically
>     being a value from 10-50. Your kriging call would then be:
>
>     k10 <- krige(yield ~ 1, canmod.sp, newdata = grd.pts,
>     model=sph.mod, nmax = n)
>
>     Hope this helps,
>     Jon
>
>
>         Thank you.
>
>         Moshood
>
>
>
>
>
>
>
>
>           where cross validation. Please guide me on how to go about
>         this using the
>         above details. Note that my observation size is 12,500 records.
>
>                 [[alternative HTML version deleted]]
>
>         _______________________________________________
>         R-sig-Geo mailing list
>         R-sig-Geo@r-project.org <mailto:R-sig-Geo@r-project.org>
>         https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
>     -- 
>     Jon Olav Skøien
>     Joint Research Centre - European Commission
>     Institute for Environment and Sustainability (IES)
>     Land Resource Management Unit
>
>     Via Fermi 2749, TP 440,  I-21027 Ispra (VA), ITALY
>
>     jon.skoien@jrc.ec.europa.eu <mailto:jon.skoien@jrc.ec.europa.eu>
>     Tel: +39 0332 789206 <tel:%2B39%200332%20789206>
>
>     Disclaimer: Views expressed in this email are those of the
>     individual and do not necessarily represent official views of the
>     European Commission.
>
>     _______________________________________________
>     R-sig-Geo mailing list
>     R-sig-Geo@r-project.org <mailto:R-sig-Geo@r-project.org>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>


-- 
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Environment and Sustainability (IES)
Land Resource Management Unit

Via Fermi 2749, TP 440,  I-21027 Ispra (VA), ITALY

jon.skoien@jrc.ec.europa.eu
Tel:  +39 0332 789206

Disclaimer: Views expressed in this email are those of the individual and do not necessarily represent official views of the European Commission.



	[[alternative HTML version deleted]]

