[ncl-talk] How to superpose shapefiles in a panelplot?

Tabish Ansari tabishumaransari at gmail.com
Mon Mar 23 06:12:27 MDT 2015


Hi

I am able to successfully superpose shapefile over my plots in NCL, however
when I make a panel plot (in this case two panels in one figure), I am
confused about how to include the shapefile individually over each panel. I
am pasting my script below: it works fine when I comment out the shapefile
procedures. Could you please help me with the correct arrangement and
sequence of the statements?

;   Example script to produce plots for a WRF real-data run,
;   with the ARW coordinate dynamics option.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;load "./WRFUserARW.ncl"

begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
  a = addfile("../wrfout_d01.nc","r")

; We generate plots, but what kind do we prefer?
  type = "x11"
; type = "eps"
; type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"panelplot_shapefile")

; Set some basic resources
  res = True
  pltres = True
  mpres = True
  res at cnFillOn          = True               ; Create a color fill plot

; Plotting options
  mpres             = True   ; Set map options
  mpres at mpOutlineOn = False  ; Turn off map outlines
  mpres at mpFillOn    = False  ; Turn off map fill
  pltres at PanelPlot  = True   ; Tells wrf_map_overlays not to remove overlays
  opts = res
  opts at gsnSpreadColorEnd = -3  ; End third from the last color in color map

; What times and how many time steps are in the data set?
  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file
  print (ntimes)
  plot = new (2, graphic)
  do it = 12,ntimes-1,1             ; TIME LOOP
    print("Working on time: " + times(it) )
    res at TimeLabel = times(it)   ; Set Valid time to use on plots
    oh =a->ho(it,0,:,:)
    rh  = wrf_user_getvar(a,"rh2",it)     ; Relative humidity
    contour_oh = wrf_contour(a,wks,oh,opts)
    contour_rh = wrf_contour(a,wks,rh,opts)
    plot(0) = wrf_map_overlays(a,wks,(/contour_oh/),pltres,mpres)
    plot(1) = wrf_map_overlays(a,wks,(/contour_rh/),pltres,mpres)

    ;india_shp_name    = "../India-shapefilefull/India_Country.shp"
    ;lnres                  = True
    ;lnres at gsLineColor      = "black"
    ;lnres at gsLineThicknessF = 1.5
    ;india_id =
gsn_add_shapefile_polylines(wks,plot(0),india_shp_name,lnres)
    ;india_id =
gsn_add_shapefile_polylines(wks,plot(1),india_shp_name,lnres)
    ;draw(plot(0))       ; This will draw the map and the shapefile
outlines.
    ;draw(plot(1))       ; This will draw the map and the shapefile
outlines.
    ;frame(wks)       ; Advance the frame

    pnlres                            = True
    gsn_panel(wks,(/plot/),(/1,2/),pnlres)


 end do        ; END OF TIME LOOP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

end

I need help with the statements shown in red color above.

Thanks in advance!

Tabish
--------------------------------------------------------------------------------------
Tabish U Ansari
MS Research Scholar
Environmental & Water Resources Engineering Division
Department of Civil Engineering
IIT Madras
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150323/741c1aa9/attachment.html 


More information about the ncl-talk mailing list