Re: matching 2 grids [message #47853 is a reply to message #47850] |
Wed, 08 March 2006 16:17   |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Jenny wrote:
> Hi all,
>
> I have 2 sets of lat/lon pairs in different grids - grid1 and grid2,
> both in irregular shape and I've filled some zero numbers to make them
> regular. grid2 is a subset of grid1. I want to find the coordinates of
> x1,y1 in grid1 (lat1/lon1) which are closest to each of the nonzero
> lat2/lon2 paris in grid2.
>
> I made a programm with several loops, it is kind of did what I want,
> but it is very slow and the boundary is not tidy. my grid1 is 600*600,
> and I have 10 grid2 to process.
>
> Is there an IDL function that I could use in this case?
The key to solving a problems like this is to make use of any geometric
structure in the grid (and here I mean the grid you're trying to locate
yourself in, ie. grid1). How irregular is grid1? I presume it's not
rectangular (ie. lon varies in one direction, lat in the other). Is it
curvilinear? Ie, does it look like a rectangular grid that has been
rotated and deformed? Or are the grid1 points just scattered with no
particular relation to each other?
For a rectangular grid, you would have a pair of 1-D location problems
of the sort that were discussed yesterday in this group under the title
"Interpolating a regular grid".
For a curvilinear grid you have a 2-D location problem. As my message
yesterday said, the Motley library has 1-D and 2-D location functions.
For a scattered set of points, I don't know. I suspect you could
approach it by first constructing a Delaunay triangulation for grid1
(see function TRIANGULATE) and then performing a nearest-neighbour
interpolation with GRIDDATA. Give each grid1 point a unique data value,
then the interpolated value on the grid2 points is the value associated
with the nearest grid1 point--something like that.
--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|