I believe the interpp() function from the akima package will do what you want.
-Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 7/28/14, 6:07 AM, "Kulupp" <kul...@online.de> wrote: >Dear R-experts, > >I have a regular grid dataframe (here: the first 50 rows) : > ># data frame (regular grid) with x, y (UTM-coordinates) and z (depth) ># x=UTM coordinates (easting, zone 32) ># y=UTM coordinates (northing, zone 32) ># z=river-depth (meters) >df <- data.frame(x=c(3454240, 3454240, 3454240, 3454240, 3454240, >3454250, 3454250, 3454250, 3454250, 3454250, 3454250, 3454250, 3454250, >3454250, 3454250, 3454250, > 3454250, 3454250, 3454260, 3454260, 3454260, >3454260, 3454260, 3454260, 3454260, 3454260, 3454260, 3454260, 3454260, >3454260, 3454260, 3454260, > 3454260, 3454260, 3454260, 3454260, 3454260, >3454260, 3454260, 3454260, 3454270, 3454270, 3454270, 3454270, 3454270, >3454270, 3454270, 3454270, > 3454270, 3454270), > y=c(5970610, 5970620, 5970630, 5970640, 5970650, >5970610, 5970620, 5970630, 5970640, 5970650, 5970660, 5970670, 5970680, >5970690, 5970700, 5970710, > 5970720, 5970730, 5970610, 5970620, 5970630, >5970640, 5970650, 5970660, 5970670, 5970680, 5970690, 5970700, 5970710, >5970720, 5970730, 5970740, > 5970750, 5970760, 5970770, 5970780, 5970790, >5970800, 5970810, 5970820, 5970610, 5970620, 5970630, 5970640, 5970650, >5970660, 5970670, 5970680, > 5970690, 5970700), > z= c(-1.5621, -1.5758, -1.5911, -1.6079, -1.6247, >-1.5704, -1.5840, -1.5976, -1.6113, -1.6249, -1.6385, -1.6521, -1.6658, >-1.6794, -1.6930, -1.7067, > -1.7216, -1.7384, -1.5786, -1.5922, -1.6059, >-1.6195, -1.6331, -1.6468, -1.6604, -1.6740, -1.6877, -1.7013, -1.7149, >-1.7285, -1.7422, -1.7558, > -1.7694, -1.7831, -1.7967, -1.8103, -1.8239, >-1.8376, -1.8522, -1.8690, -1.5869, -1.6005, -1.6141, -1.6278, -1.6414, >-1.6550, -1.6686, -1.6823, > -1.6959, -1.7095)) >head(df) >plot(df[,1:2], las=3) # to show that it's a regular grid > >My question: is there a function to calculate the depth of any >coordinate pair (e.g. x=3454263, y=5970687) within the grid, e.g. by >bilinear interpolation or any other meaningful method? > >Thanks a lot for your help in anticipation > >Best wishes > >Thomas > >______________________________________________ >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. ______________________________________________ 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.