[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Map spanning Dateline?



Charlotte DeMott wrote:
> 
> How about this example:
> 
> map_set, 0, 180, limit=[-20,0,20,360]
> 
> so far so good, but how do i get latitude labels to appear to the LEFT of
> the map?  Setting latlab=-20, causes the labels to appear at 340 degrees
> (IN the map, near the rhs).
> 
> charlotte
> 

yes, that *is* cumbersome. I attach a little routine that will take care
of your
labelling issues. The basic idea is to use XYOUTS. Once you are there,
you can
then really spruce your maps up quite a bit. As an example, I add a
degree symbol...

Hope this helps,
Martin.


-- 
-------------------------------------------------------------------
Dr. Martin Schultz                   
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax  : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
-------------------------------------------------------------------

function get_gridspacing,range,delta=delta,n=n

   ; return 5, 10, 15, 30 depending on range

   dist = range[1]-range[0]
   if (dist gt 120.) then delta = 30. $
   else if (dist gt 80.) then delta = 15. $
   else if (dist gt 45.) then delta = 10. $
   else delta = 5.

   ; set up mega grid and truncate to actual range
   ; range shouldn't exceed -180 or +720 in any case
   ; therefore we start with a grid of 900/5 = 150 entries 
   grid = findgen(150)*delta - 180.

   keep = where(grid ge range[0] AND grid le range[1])
   if (keep[0] eq -1) then message,'Invalid parameters for grid!'

   grid = grid[keep]
   n = n_elements(keep)

   return,grid
end


pro map_labels,lonrange=lonrange,latrange=latrange

   if (n_elements(latrange) ne 2) then latrange = [ -90., 90. ]
   if (n_elements(lonrange) ne 2) then lonrange = [ -180., 180. ]

   center = [ total(latrange)/2., total(lonrange)/2. ]

   map_set,center[0],center[1],  $
         limit=[latrange[0],lonrange[0],latrange[1],lonrange[1]],  $
         color=1,position=[0.2,0.3,0.9,0.8],/continents


   ; degree symbol
   deg = '!Uo!N'

   ; compute grid lines
   lats = get_gridspacing(latrange,n=nlat)
   lons = get_gridspacing(lonrange,n=nlon)

   map_grid,color=1,lats=lats,lons=lons

   ; convert to normal coordinates for labeling
   ; norm... will be 3 dimensional arrays. 1st coordinate is
   ; longitude, 2nd is latitude. For lats, the longitude is at
   ; the left of the plot, for lons, the latitude is on the bottom
   ; Thus, it's easy to use this information for xyouts

   dumlat = fltarr(nlon) + latrange[0]
   dumlon = fltarr(nlat) + lonrange[0]
   normlats = convert_coord(dumlon,lats,/DATA,/TO_NORMAL)
   normlons = convert_coord(lons,dumlat,/DATA,/TO_NORMAL)

   charheight=0.005  ; estimated

   xyouts,normlats[0,*]-0.018,normlats[1,*]-charheight,  $
        strtrim(string(lats,format='(I5)'),2)+deg,/NORM, $
        align=1.,color=1

   xyouts,normlons[0,*],normlons[1,*]-0.025,  $
        strtrim(string(lons,format='(I5)'),2)+deg,/NORM, $
        align=0.5,color=1

return
end