Re: overlaying raster over other fields

From: Joe Grim <grim_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 08 2010 - 16:52:14 MST

Hi,

I finally got it figured out, thanks to your help. Daran got me pointed in
the right direction, and Mary's example code (missing.ncl) helped give me a
framework to work with. I had several problems, so I won't go into what was
wrong. Instead, I thought I would just include my relevant snipet of code
below, in case anyone else ever needs something like this. What it does is:

1) plots a "CellFill" on "plot" (I had to do this initially to set up the
lat/lon base; there's probably a better way, but this was the best I could
figure out.)
2) adds several polygons onto "plot"
3) plots a "CellFill" plot again, but this time on "plot2"
4) adds a polyline onto "plot2"
5) overlays "plot2" onto "plot"

  PlotName = "overlay_plot"
  wks = gsn_open_wks("ps",PlotName) ; open a ps file
  gsn_merge_colormaps(wks,"WhViBlGrYeOrReWh","gsdtol")

  setvalues NhlGetWorkspaceObjectId()
  "wsMaximumSize": 1500000000
  end setvalues

  res = True ; plot mods desired
  res@gsnDraw = False ; do not draw the
plot
  res@gsnFrame = False
  res@cnFillOn = True ; turn on color fill
  res@cnFillMode = "CellFill"
  res@gsnSpreadColors = True ; use full range of
colors
  res@gsnSpreadColorStart = 101
  res@gsnSpreadColorEnd = 3
  res@cnLinesOn = False
  res@cnLevelSelectionMode = "ManualLevels" ; manually set the contour
levels with the following 3 resources
  res@cnMissingValFillColor = -1
  res@cnMissingValFillPattern = -1
  res@cnMinLevelValF = min_contour ; set the minimum
contour level
  res@cnMaxLevelValF = max_contour ; set the maximum
contour level
  res@cnLevelSpacingF = cntr_intrvl ; set the interval
between contours
  res@gsnMaximize = True ; uncomment to maximize size
  res@vpWidthF = (max_lon -
min_lon)*cos((max_lat+min_lat)/2.*2.*3.14159/360.)
  res@vpHeightF = max_lat - min_lat
  res@pmTickMarkDisplayMode = "NoCreate"
  res@gsnMaximize = True
  res@gsnPaperOrientation = "landscape"
  res@lbAutoManage = False
  res@lbLabelStride = 6
  res@lbBoxLinesOn = False
  res@lbLabelFontHeightF = 0.015
  res@lbTitlePosition = "Bottom"
  res@lbTitleFontHeightF = 0.015
  res@pmLabelBarOrthogonalPosF = 0.00 ; position the label bar
  res@pmLabelBarHeightF = 0.2
  res@cnInfoLabelOn = False
  res@gsnLeftString = ""
  res@gsnRightString = ""

;make the contour plot
  plot = gsn_csm_contour(wks,full_array,res)

  ; polygon resources
  res_poly = True
  res_poly@gsEdgesOn = False ; draw border around polygons
  res_poly@gsEdgeColor = "black"
  res_poly@gsFillColor = "gray"
  do ii=0,n_polys-1
   gsn_polygon (wks,plot,lon_arr(ii,:),lat_arr(ii,:),res_poly)
  end do

  draw(plot) ; draw the plot

  res@gsnDraw = False ; do not draw the plot
  res@gsnFrame = False

  plot2 = gsn_csm_contour(wks,full_array,res)

  resp = True
  resp@gsLineColor = "black"
  resp@gsLineThicknessF = 0.5
  dum = gsn_add_polyline(wks,plot2,lons,lats,resp)

  draw(plot2) ; draw the plot
  frame(wks)

  overlay(plot,plot2)

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 8 16:52:29 2010

This archive was generated by hypermail 2.1.8 : Fri Dec 10 2010 - 14:58:12 MST