![](https://secure.gravatar.com/avatar/764323a14e554c97ab74177e0bce51d4.jpg?s=120&d=mm&r=g)
On Sat, Sep 26, 2009 at 06:34, John [H2O] <washakie@gmail.com> wrote:
Raising the issue again, because I am still having problems.
To explain my situation once more, I have a set of non-regular data spanning the N Pole. I want to interpolate it to a regular lat/lon grid.
Here is my current approach: # data_lon,data_lat are lat/lon pairs, irregularly spaced # m is a npstere basemap instance x,y = m(data_lon,data_lat) reg_lon = np.arange(lon.min(),lon.max()+dres,dres) nx = reg_lon.size reg_lat = np.arange(lat.min(),lat.max()+dres,dres) ny = reg_lat.size grid_lon,grid_lat = m.makegrid(nx,ny)
# find the projected co-ordinates for the grid grid_x, grid_y = m(grid_lon, grid_lat) print "Using Triangulation" # triangulate data tri = delaunay.Triangulation(x,y) # interpolate data interp = tri.nn_interpolator(z) Z0 = interp(grid_x, grid_y)
This works fine, however, I note that grid_lon, grid_lat are no longer equal to reg_lon, reg_lat. So it seems that my Z0 is not spaced regularly as reg_lon,reg_lat but rather according to grid_lon,grid_lat.
This is fine for mapping in a projected space (i.e. using the basemap instance), but how can I 'reverse transform' the data back so that it has reg_lon,reg_lat as it's coordinates?
Just transform reg_lon,reg_lat to the projection space an interpolate using that. Z0 = interp(*m(reg_lon, reg_lat)) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco