Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Re: Q: Lat/Lon to gridpoint interpolation
In article <3ngi2i$6m8@spool.cs.wisc.edu>, Liam Gumley <liamg@ssec.wisc.edu> writes: |> Hey folks, |> |> I have two arrays, one is latitude and the other longitude. These |> lat/lons correspond to satellite sensor fields-of-view on the earth |> surface, and are irregularly spaced. I am trying to come up with a method |> of finding the array indices closest to a given lat/lon, without having to |> do a search of the lat/lon arrays. This is so that I can lay a coastline over |> an un-resampled satellite image. I have already found a couple of ways to |> do it by array searching, and it's a bit cumbersome. |> |> I can't figure out how to do it using a simple fitting algorithm. What I want |> to do is this: |> |> lat is an x by y real array |> lon is an x by y real array |> |> I want to find the fractional x, y corresponding to a given lat, lon. |> |> Any suggestions? |> POLYWARP can be used to find polynomial fit coefficients which will take lat and lon as inputs and return ix and iy, the satellite sample and line indecies. The call to polywarp goes like, polywarp,xi,yi,lon,lat,degree,kx,ky where lon and lat are your satellite longitude and latitude fields and xi and yi are the satellite sample and line indecies they correspond to, degree is the degree of the polynomial fit (try 2) and kx and ky are the polynomial coefficients such that ix=poly_2d(alon,alat,kx) iy=poly_2d(alon,alat,ky) This whole procedure will work fine as long as your lat and lon fields aren't too distorted. You'll have trouble near the geographic poles. -- ____________________________________________________________ _______________ Paul Ricchiazzi email: paul@icess.ucsb.edu Institute for Cumputational Earth System Science University of California, Santa Barbara If I have seen farther than | If I have not seen as far as others, it is by standing on | others, it is because giants the shoulders of giants. | were standing on my shoulders. | Isaac Newton | Hal Abelson ____________________________________________________________ _______________