[R] Calculate depth from regular xyz grid for any coordinate within the grid

Sarah Goslee sarah.goslee at gmail.com
Mon Jul 28 15:35:38 CEST 2014


Hi,

The area of statistics you're looking for is called geostatistics.
There are many R packages to conduct such analyses. See the Spatial
task view for some good starting points:

http://cran.r-project.org/web/views/Spatial.html

You'll need to do some homework to understand the various options and
which are best for your data. You might start with Inverse Distance
Weighting.

Sarah

On Mon, Jul 28, 2014 at 9:07 AM, Kulupp <kulupp at 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
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list