There's no universal way to do it.  If your data are not yet ordered,  
I suggest triangulating them using one of the Delaunay triangulation  
codes (for which you can Google).  That will give you a tiling of the  
plane into triangles defined by nearby data points.  Once you've done  
that, it's a "trivial" matter to interpolate values onto a structured  
grid:  you can hop from triangle to triangle in the general direction  
of the desired point, until you find the triangle that encloses your  
grid point.  That triangle defines a trio of data points from which  
you interpolate the value at the grid location.  If you loop  
boustrophedonically down your grid then the triangle-searching step  
will be extremely fast.

PDL itself is not so great at this kind of unstructured data problem  
-- your best bet is to handle it in a PP or C subroutine that you  
access through either the PDL::Inline module or the PP metalanguage.   
You could prototype your code in Perl, but if you are going into  
production it will be worth your while to write the compiled routine  
to do it.

While I can't dive into the problem for the next 2-3 months, I'd be  
interested in seeing this happen -- it would be a nice addition to the  
PDL image library, and several other folks have had similar problems  
over the years.

(Hmmm... I just realized that there's a "quick and dirty" way to to  
this - once you've triangulated your data points I bet you could use  
GL to do the interpolation for you.  It's intended for graphics  
rendering, but GL can handle floating point "brightness" values.  It  
can also render to an array in memory, which you could hand back to  
the user.  That has the advantage that on most systems the  
interpolation will run at GPU pipeline speed rather than plodding CPU  
speed, and of course GL renders are meant to be completely  
reproducible to within machine roundoff on different systems.)





On Apr 30, 2009, at 8:34 AM, Steve Longmore wrote:

> Hi,
>
> I'm trying to grid an irregularly sampled data set onto a linear 2D  
> grid
> but am struggling to find a function to do this. I was hoping someone
> could point me to a simple way of doing this.
>
> Thanks,
> Steve
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to