Paul Heinrich Dietrich
2009-Aug-16 15:33 UTC
[R] How to use your own data in gstat and sp?
This seems pretty basic, but I can't get any data to work except for the documented examples. When the goal is to get to SpatialPixels, here is what I see...> x <- runif(10,1,10) > y <- runif(10,1,10) > z <- rnorm(10,0,1) > MyData <- as.data.frame(cbind(x,y,z)) > library(gstat) > coordinates(MyData) <- ~x + y > gridded(MyData) <- TRUEsuggested tolerance minimum: 0.893182669294186 Error in points2grid(points, tolerance, round, fuzz.tol) : dimension 1 : coordinate intervals are not constant I've spent way too much time trying to get my data to work. Please help. Thanks. -- View this message in context: http://www.nabble.com/How-to-use-your-own-data-in-gstat-and-sp--tp24994744p24994744.html Sent from the R help mailing list archive at Nabble.com.
First re-read the definition of what a SpatialPixels object is - ?"SpatialPixels-class" - note that it says: "class for defining a pixels, forming a possibly incomplete rectangular grid of arbitrary dimension". When you try to coerce a SpatialPointsDataFrame to a SpatialPixelsDataFrame, it is checked to see that the points form a "possibly incomplete rectangular grid". Your points are random within a 1,10 square, so only regularly spaced for a very special setting of the seed of the RNG, right? Since you are unlikely to hit that very, very rare seed at random, you are not likely to generate a regular grid in this way. Did you examine the class(), summary() and str() of the input data in the examples? Hope this helps, Roger Bivand PS. consider following this up on the R-sig-geo list. Paul Heinrich Dietrich wrote:> > This seems pretty basic, but I can't get any data to work except for the > documented examples. When the goal is to get to SpatialPixels, here is > what I see... > >> x <- runif(10,1,10) >> y <- runif(10,1,10) >> z <- rnorm(10,0,1) >> MyData <- as.data.frame(cbind(x,y,z)) >> library(gstat) >> coordinates(MyData) <- ~x + y >> gridded(MyData) <- TRUE > suggested tolerance minimum: 0.893182669294186 > Error in points2grid(points, tolerance, round, fuzz.tol) : > dimension 1 : coordinate intervals are not constant > > I've spent way too much time trying to get my data to work. Please help. > Thanks. >-- View this message in context: http://www.nabble.com/How-to-use-your-own-data-in-gstat-and-sp--tp24994744p25004460.html Sent from the R help mailing list archive at Nabble.com.
Maybe Matching Threads
- using shapefiles in adehabitat/ converting shapefile to spatial pixel data frame
- variograms and kriging
- Are centre coordinates or upper left corners used of x, y for SpatialPixels?
- Getting polygons from contiguous grid cells having same value in sp
- 3d kriging et al