Re: Another triangulate/griddata question [message #75363] |
Sun, 06 March 2011 18:38 |
BLesht
Messages: 89 Registered: March 2007
|
Member |
|
|
On Mar 4, 8:15 am, Barry Lesht <ble...@gmail.com> wrote:
> Thank you, Ben. I'll take a look at GRID_INPUT and see what happens.
> Barry
Ben - GRID_INPUT didn't help. What did help was fixing a bug that had
west longitudes being entered as positive rather than negative
values. Duh! Thanks again for your suggestion. Barry
|
|
|
|
Re: Another triangulate/griddata question [message #75375 is a reply to message #75370] |
Wed, 02 March 2011 16:55  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On 3/2/11 2:56 PM, Barry Lesht wrote:
> I have a problem that I thought would be easy to solve using griddata
> as David Fanning did in his tip (http://www.idlcoyote.com/code_tips/
> usegriddata.html). As input I have some 2D data arrays (can be either
> 512x512 or 1024x1024) with a longitude and latitude value associated
> with each element. I want to output data arrays that represent sub-
> regions of the input arrays in a particular map projection. Being sub-
> regions, the output arrays are smaller than the input arrays. I know
> the dimensions of the output arrays (xSize,ySize) as well as their
> geographic limits (limits) and geographic position
> (xStartDeg,yStartDeg) of the lower left corner.
>
> Following David's example, I do the following:
>
> mapStruct = MAP_PROJ_INIT('CYLINDRICAL', LIMIT=limit)
> xy = MAP_PROJ_FORWARD(lons, lats, MAP_STRUCTURE=mapStruct)
> x = REFORM(xy[0,*], xIn, yIn) ; xIn, yIn
> based on input array size
> y = REFORM(xy[1,*], xIn, yIn)
> ;
> ; Get the x, y coordinates of the ouput array southwest corner
> ;
> llxy = MAP_PROJ_FORWARD(xStartDeg, yStartDeg, MAP_STRUCTURE=mapStruct)
> xStart=llxy[0]
> yStart=llxy[1]
> ;
> TRIANGULATE, x, y, triangles, TOLERANCE=1.0
> griddedData = GRIDDATA(x,y,wtmp,/NEAREST_NEIGHBOR,
> TRIANGLES=triangles, DIMENSION=[xSize,ySize], MISSING=nan,
> START=[xStart,yStart])
>
> This fails with the error: % GRIDDATA: Value of Triangle index is out
> of allowed range.
>
> I'm not sure why this is happening. Could it be because some of the
> triangles that are defined in the triangulate step are completely
> outside the domain of the defined subregion? If so, is there a way
> around this? Thanks.
Hi,
As a starting point it is always good to run your points through
GRID_INPUT before sending them along to GRIDDATA. There isn't anyway to
be sure that this solves things but it is a simple thing to try.
Cheers,
Ben
|
|
|