comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: map_image and latmin/latmax, lonmin/lonmax - edges or centres?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: map_image and latmin/latmax, lonmin/lonmax - edges or centres? [message #86045 is a reply to message #86044] Thu, 26 September 2013 06:17 Go to previous messageGo to previous message
Andy Sayer is currently offline  Andy Sayer
Messages: 127
Registered: February 2009
Senior Member
Ok, here is some code which will reproduce the problem (IDL 7.1.1). This should draw an image in a 5x5 degree box from 47-52 N, 115-110 W. It puts the image in the right place, but the edge columns and rows are chopped in half in size (they should all be the same size). So you can see that this means all the points are offset from where they really should be. Does anyone know what is happening here?

; Define some dummy data
datavals=intarr(5,5)
for i=0,4 do begin
for j=0,4 do begin
datavals[i,j]=i+j
endfor
endfor

; Scale the data to byte range 0=255
scaled_data=1+254*(datavals)/max(datavals)

; Load a colour table
loadct,3

; Set up a map projection covering the region of interest and a bit more
window,0
map_set,latdel=1,londel=1,limit=[45,-118,55,-108],/noborder, xmargin=[2,2],ymargin=[2,2]

; Scale image to data: assume the 5x5 grid is a dataset at 1 degree resolution.
; So put the box from, say, 47-52 N, 115 to 110 W

cola = map_image(scaled_data,startx,starty,xsize,ysize,compress=1,$
latmin=47.0,latmax=52.0,$
lonmin=-115.,lonmax=-110.)

; Put the image on the map
tv,cola,startx,starty,xsize=xsize,ysize=ysize

; Add borders
map_continents,/usa

end

On Thursday, September 26, 2013 8:50:59 AM UTC-4, AMS wrote:
> I keep meaning to rewrite my mapping routines to include GSHHS but didn't get round to it yet... :)
>
>
>
> I think in this case it isn't the IDL borders & boundaries database which is in the wrong, but rather my use of map_image. The reason is that if I draw the data in my image pixel-by-pixel using polyfill it lines up exactly correctly, and it's only when I use map_image that the data is offset from where it should be. So something must be up with these offsets.
>
>
>
> Andy
>
>
>
> On Wednesday, September 25, 2013 4:35:01 PM UTC-4, David Fanning wrote:
>
>> AMS writes:
>
>>
>
>>
>
>>
>
>>> After fiddling some more, I agree that it's probably the outer coordinates of the image rectangle that it wants. However, I'm still encountering some odd behaviour. For example, if I take regular 1 degree gridded data and try to map that, things like the US-Canada border (at 49 degrees N) don't lie exactly on grid cell borders (as they should) but are slightly shifted. I'm going to leave it for the rest of the day in case my overtired mind is overlooking something, but
>
>>
>
>> if I can't figure it out tomorrow, will create some code which reproduces the issue and post it.
>
>>
>
>>
>
>>
>
>> You might find that the GSHHS database is more accurate than the
>
>>
>
>> database that comes with IDL:
>
>>
>
>>
>
>>
>
>> http://www.idlcoyote.com/map_tips/gshhs.html
>
>>
>
>>
>
>>
>
>> Cheers,
>
>>
>
>>
>
>>
>
>> David
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> --
>
>>
>
>> David Fanning, Ph.D.
>
>>
>
>> Fanning Software Consulting, Inc.
>
>>
>
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
>>
>
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to read string data from excel file
Next Topic: combination of two integration methods in a specified time interval

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:09:54 PDT 2025

Total time taken to generate the page: 0.00251 seconds