Re: Looking for *simple* example of annotating a lat-lon plot

From: Dennis Shea (shea AT XXXXXX)
Date: Fri Jun 04 2004 - 09:19:33 MDT

  • Next message: Derrick Snowden: "status of python modules"

    (1) as noted by Sylvia see:

    http://www.cgd.ucar.edu/csm/support/CSM_Graphics/index_bycat.shtml
    If you are new to NCL, become very familiar with this WWW.
    It has many examples.

    Then click under "Polymarker" and/or "Text".
    I also suggest Sylvia's "Trajectory" examples under "Special Effects"

    (2) Specifically, looking at your sample script:

        [a] There is no need for "wmsetp". In this case it has no effect
        
        [b] The use of "gsn_text_ndc" is not what you want.
            This procedure expects the coordinates to be in "viewport"
            (ie, absolute) coordinates. You are using lat/lon coordinates.
            
            gsn_text or gsn_add_text would be the appropriate
            procedure/function.
            
        [c] I would suggest the "gsn_add_text" or "gsn_add_polymarker"
        
    (3) Generally, I would say it is best to not draw the map
        immediately [ie res@gsnDraw = False]. Then add other
        'stuff' [text/lines/markers] via "gsn_add_*" to the
        plot object .... then draw.
        
    (4) I took your script/then extracted a few lines from
        some example scripts. Try the following:

    ;load "$NCARG_ROOT/ncarg/nclscripts/csm/gsn_code.ncl"
    ;load "$NCARG_ROOT/ncarg/nclscripts/csm/gsn_csm.ncl"
        
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    ; ================================================;
    begin
      title = "bouy locations"
      blat = (/46.77/)
      blon = (/-48.016/)

    ; ****************************************************
      wks = gsn_open_wks("x11","satBouy") ; open a pdf file
      gsn_define_colormap(wks,"testcmap") ; choose colormap
      i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to map

      res = True ; plot mods desired
      res@mpProjection = "Satellite" ; choose map projection
      res@mpCenterLonF = -75. ; choose center lon
      res@mpCenterLatF = 35. ; choose center lat
      res@mpLimitMode = "LatLon" ; required
      res@mpMinLatF = 8. ; min lat
      res@mpMaxLatF = 65. ; max lat
      res@mpMinLonF = -110. ; min lon
      res@mpMaxLonF = -40. ; max lon
      res@mpGridAndLimbOn = True ; turn on lat/lon lines
      res@mpGridLatSpacingF = 5 ; Lat spacing (degrees)
      res@mpGridLonSpacingF = 5 ; Lon spacing (degrees)
      res@mpGridMaskMode = "MaskLand" ; Mask grid over land.
     ;res@mpGridMaskMode = "MaskNone" ; Mask grid over land.
      res@mpPerimOn = False ; Turn off perimeter
      res@tmXTLabelsOn = False ; Turn off top lon/label

      res@pmTickMarkDisplayMode = "Always" ; turn on automatic tickmarks

      res@tiMainString = title

     ;res@gsnAddCyclic = False ; only for gridded non global data
      res@gsnMaximize = True ; enlarge plot
      res@gsnDraw = False ; False: do not draw immediately
      res@gsnFrame = False ; False: explicit advance frame

      plot = gsn_csm_map(wks,res) ; Create map object
                                             
      pmrkres = True ; add polymarker(s) to map object
      pmrkres@gsMarkerIndex = 16 ; polymarker style
      pmrkres@gsMarkerSizeF = 10. ; polymarker size
      mark = gsn_add_polymarker(wks,plot,blon, blat,pmrkres)

      txres = True ; add text to map object
      txres@txFontHeightF = 0.03 ; font smaller. default big
      text = gsn_add_text(wks,plot,"+",blon-2, blat-2,txres) ; offset for clarity

    ; create points for box
      ypts = (/ 43.0, 43.0, 52.0, 52.0, 43.0/) ; must be 'cyclic'
      xpts = (/-52.5, -44.0,-44.0, -52.5,-52.5/)
      npts = dimsizes(xpts)

      plres = True ; polyline mods desired
      plres@gsLineColor = "red" ; color of lines
      plres@gsLineThicknessF = 2.0 ; thickness of lines

      line = new(npts-1,graphic) ; gsn_add_polyline requires 1d array

    ; draw each line separately. Each line must contain two points.
      do i=0,npts-2
         line(i)=gsn_add_polyline(wks,plot,xpts(i:i+1),ypts(i:i+1),plres)
      end do

      draw(plot) ; draw plot object
      frame(wks) ; advance frame

      end

            
            

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Fri Jun 04 2004 - 14:23:00 MDT