On Dec 2, 2013, at 8:02 PM, Mercutio Florid wrote: > I want to map out a mostly flat area of land, 300 meters on a side. > > > I want to make (x,y,z) triples where x and y vary between -150 and 150 and > there is just one z value. > > > Eventually I will try to use graphics to actually draw this, but my first > problem is that I need to get 90601 values by interpolating just 13 actual > measurements. The measurements are currently unsorted, which might cause > errors with some functions, and they are in a matrix that looks like this: > X Y Value > 1 20 135 105 > 2 -127 69 106 > 3 -98 47 107 > 4 -39 69 105 > 5 49 47 105 > 6 108 69 107 > 7 -9 3 106 > 8 -39 3 106 > 9 -127 -63 105 > 10 -39 -41 108 > 11 -39 -107 106 > 12 79 -63 107 > 13 20 -129 107
I have no idea what sort of "interpolation would make sense here. There is an 'akima' package that does interpretation at irregularly located x-y coordinates, but after doing a planar fit with scatter3d (which also lets you look at the points in 3d, I think your points have a rather irregular cliff-like structure. rd.txt <- function (txt, header = TRUE, ...) { rd <- read.table(textConnection(txt), header = header, ...) closeAllConnections() rd } dat <- rd.txt(" X Y Value 1 20 135 105 2 -127 69 106 3 -98 47 107 4 -39 69 105 5 49 47 105 6 108 69 107 7 -9 3 106 8 -39 3 106 9 -127 -63 105 10 -39 -41 108 11 -39 -107 106 12 79 -63 107 13 20 -129 107") library(car) # will also need rgl scatter3d(dat$X, dat$Y, dat$Value) library(akima) akima.li <- interp(dat$X, dat$Y, dat$Value, xo=seq(min(dat$X), max(dat$X), length = 100), yo=seq(min(dat$Y), max(dat$Y), length = 100)) persp(akima.li$z) persp(akima.li$z, theta=30) persp(akima.li$z, theta=45) persp(akima.li$z, theta=60) -- David. > > > The syntax for the output seems pretty easy: > x_coord<-seq(from=-150,to=150) > y_coord<-seq(from=-150,to=150) > planebreadth=301 > spaceArray<-array(0,c(planebreadth, planebreadth,1)) > > But what I need to do is somehow interpolate 90601 values into spaceArray, > based on just 13 measurements. > > I looked through some introductory R tutorials such as > > cran.r-project.org/doc/manuals/R-intro.html > > and I didn't see any examples that seemed to cover this kind of problem. > > > > I did some web searches and there seem to be many, many ways to do > interpolation. There are packages like mgcv and DiceKriging. There are > various packages that mention splines in their descriptions, such as cobs. > > What is the easiest way to interpolate this kind of data? Thanks. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.