1

Probably it is a newbie question, but I search for a while and unfortunately I did not find anything, which fits to my problem. I want to do a spatial interpolation between one finer irregular grid to one coarser irregular gird.

The Problem: I have longitude and latitude coordinates (both are 2-dimensional arrays,100x100 (not a vector)) of the finer grid (1km grid resolution) and also two arrays (450x450) for longitude and latitude of the coarser gird (3km grid resolution). Now i want to interpolate temperature and humidity from the finer resolution to the coarser resolution to compare the temperature and humidity profiles. The area of the finer resolution completely fill in the coarser one (about 35x35 gridpoints in the coarser one).

Try I tried to realize it on two ways. First i tried to do a kind of nearest neighbor interpolation. I searched the nearest neighbor on the spheric and than mean the values of the finer grid to the position of the coarser grid. I know that this was guick and dirty but it unfortunately delivers unrealistic results (you get stripes in the horizontal). Here is the code of the first try:

 source("~/getnearest.r")
 distance <- gp_neigh <- array(NA,c(length(var_finer_rho[,1]),length(var_finer_rho[1,])))
 for (i_lon in 1:length(var_finer_rho[,1])){
 for (i_lat in 1:length(var_finer_rho[1,])){
   distance <- get_nearest(lat_finer_res[i_lon,i_lat],lat_coarser_res,lon_finer_res[i_lon,i_lat],lon_coarser_res)
   gp_neigh[i_lon,i_lat]  <- which.min(distance)
 }
 }

finer_interp2c <- array(NA,c(40,40))
for (i_gp in min(gp_neigh):max(gp_neigh)){
  finer_interp2c[i_gp] <- mean(var_finer_rho[which(gp_neigh==i_gp)])
}

In the second try I transform the fields to regular grids and then interpolate the regular grid with the help of the akima package. This seems to work, but I am not sure if it is right. Because changes in the grid resolution (gridres) change influence the result of the result. And i am not so happy of the comparison in the regular grid data-set.

  gridres1=150
  gridres2=75
  library("akima")

  var_fin_interp=interp(lon_finer_res, lat_finer_res, var_finer_rho, xo=seq(min(lon_finer_res), max(lon_finer_res), length = gridres1),yo=seq(min(lat_finer_res), max(lat_finer_res), length = gridres1),linear = TRUE, extrap=FALSE, duplicate = "mean")
  var_cor_interp=interp(lon_coarser_res, lat_coarser_res, var_coearser_rho, xo=seq(min(lon_coarser_res), max(lon_coarser_res), length = gridres2),yo=seq(min(lat_coarser_res), max(lat_coarser_res), length = gridres2),linear = TRUE, extrap=FALSE, duplicate = "mean")
  loc <- make.surface.grid(list(var_cor_interp$x,var_fin_interp$y))
  interp.surface(var_fin_interp, loc)-> look

Question Is there any possibility to do an interpolation from a irregular field to an other irregular field and do anybody know how do i solve my problem?

PS: Sorry that I do not write the original variables in the code, but i did not find the possibility to bring them in the post.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
Boje
  • 11
  • 3
  • 2
    Is it possible to sttart with one of the example datasets and show us with that data so that we can see your problem and show you the solution in a replicable way? I know it's a little bit of a pain, but if you type `data()` in R you'll see a list of sample datasets, including some spatial ones which come with your package (i.e. akima760 and akima). – Hack-R Aug 27 '14 at 15:50
  • Are you sure that `akima:interp` won't do what you want? – Carl Witthoft Aug 27 '14 at 17:54
  • Unfortunately I found only one example-data set, instead of two, which you need to do the example. But I hope I can show on this data-set, which i want to do I found the data-set 'RCMexample' from library('fields') . You can see the irregular lon/lat-grid. I want to interpolate the values of the RCMexample to another irregular grid. @Carl Witthoft: I tried it with interp but it delivers nearly over the complete field NA. Here my code of the try > interp(lon_finer_grid, lat_finer_grid, variabel_finer_grid, xo=lon_coarser_grid,yo=lat_coarser_grid,linear = TRUE, extrap=FALSE, duplicate = "mean") – Boje Sep 05 '14 at 09:33

0 Answers0