爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3672|回复: 1

NCL绘制shp地图叠加与原图分离

[复制链接]
回帖奖励 1 金钱 回复本帖可获得 1 金钱奖励! 每人限 1 次(中奖概率 50%)

新浪微博达人勋

发表于 2017-10-16 16:55:37 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图:
问题概况: 对wrf_map_overlays绘制的填色风场图再采用gsn_add_shapefile_polylines命令叠加市界,生成两张图,市界未叠加在填色图上,查询比对过ncl官网例子,未找到出现此问题的原因。
我看过提问的智慧: 看过
自己思考时长(天): 3

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
附画图程序:load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin

  f = addfile("./wrfout_d03_2015-05-21_00:00:00","r")
;print(getfilevarnames(f))  ;print(f)

  type = "x11"
;  type = "pdf"
; type = "ps"
; type = "ncgm"
;  type = "png"
  wks = gsn_open_wks(type,"O3_mod_all")  ; "x11"
  gsn_define_colormap(wks,"sunshine_9lev")

;Set some basic resources
  res = True
  res@gsnMaximize =True
  res@gsnDraw    = False
  res@gsnFrame   = False
  res@InitTime              = False
  res@Footer                = False
  res@tiMainOn              = False

;Set for the map
  pltres                           = True
  pltres@FramePlot                 = True
  mpres                            = True
  mpres@mpMinLatF                  = 30.45
  mpres@mpMaxLatF                  = 35.20
  mpres@mpMinLonF                  = 116.18
  mpres@mpMaxLonF                  = 121.57

  mpres@mpDataSetName              = "/public/home/Mia/NCL-Chinamap-master/database/Earth..4"
   mpres@mpDataBaseVersion          = "MediumRes"
  mpres@mpAreaMaskingOn            = True
  mpres@mpOutlineSpecifiers        = (/"jiangsu"/);         
  mpres@mpFillAreaSpecifiers       = (/"jiangsu"/)
  mpres@mpGeophysicalLineThicknessF = 1
  mpres@mpOutlineBoundarySets      = "NoBoundaries"
  mpres@mpNationalLineColor        = "black"
  mpres@mpProvincialLineColor      = "black"
  mpres@mpGeophysicalLineColor     = "black"
  mpres@mpNationalLineThicknessF   = 2
  mpres@mpProvincialLineThicknessF = 1
  mpres@mpGridAndLimbOn            = False                ; Turn off lat/lon lines

mpres@mpProjection        = "LambertConformal"    ; choose projection
; mpres@mpLambertParallel1F = 33          ; first parallel
; mpres@mpLambertParallel2F = 45          ; second parallel
; mpres@mpLambertMeridianF  = -98         ; meridian
  mpres@mpLimitMode         = "Corners"   ; corner method of zoom
;  mpres@mpLeftCornerLatF    = 30          ; left corner
;  mpres@mpLeftCornerLonF    = 118        ; left corner
;  mpres@mpRightCornerLatF   = 35          ; right corner
;  mpres@mpRightCornerLonF   = 120         ; right corner


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  times = wrf_user_getvar(f,"times",-1) ;get all times in the file
  ntimes = dimsizes(times) ;number of times in the file

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

  do it = 30,ntimes-1,24    ;Time Loop

    print("working on time: " + times(it))
    res@TimeLabel = times(it)  ;set Valis time to use on plots

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

;First get the variables we will need

    u10 = wrf_user_getvar(f,"U10",it)
    u10@units = "m s~S~-1~N~"
    v10 = wrf_user_getvar(f,"V10",it)
    v10@units = "m s~S~-1~N~"
    o3 = f->o3(it,0,:,:)  
    O3 = o3*1000*48/22.4 ;Turn ppbm to ug/m3
    O3@description = "O~B~3~N~ Concentration"
    O3@units = "~F33~m~F0~g m~S~-3~N~"

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

;plotting options for O3

    opts = res
    opts@cnFillOn = True   ; Turn on color fill
    opts@ContourParameters = (/ 160., 300., 20./)
    contour_O3 = wrf_contour(f,wks,O3,opts)
    delete(opts)

;plotting options for Wind Vectors

    opts = res
    opts@vcFillArrowEdgeColor  = "black"
    opts@vcFillArrowFillColor  = "black"
    opts@vcMinDistanceF        = 0.08
    opts@vcMinMagnitudeF       = 2
    opts@vcGlyphStyle          = "FillArrow"
;set FillArrow
    opts@vcFillArrowEdgeThicknessF = 0.1
    opts@vcFillArrowHeadInteriorXF = 0.25
    opts@vcFillArrowHeadXF         = 0.6
    opts@vcFillArrowHeadYF        = 0.2
    opts@vcFillArrowWidthF        = 0.1
;set Ref
    opts@vcRefAnnoOn             =True
    opts@vcRefAnnoBackgroundColor = "white"
    opts@vcRefAnnoFontHeightF     = 0.015
    opts@vcRefAnnoOrthogonalPosF  = -0.12
    opts@vcRefAnnoParallelPosF    = 0.95
    opts@vcRefAnnoPerimOn         = True
    opts@vcRefAnnoSide            = "Right"
    opts@vcRefAnnoString1On       = False
    opts@vcRefAnnoString2On       = True
    opts@vcRefAnnoString2         = "10m/s"
    opts@vcRefMagnitudeF          = 10
    opts@vcRefLengthF             = 0.045

    opts@FieldTitle = "Wind" ;overwrite Field Title
    opts@NumVectors = 25     ;density of wind barbs
    vector = wrf_vector(f,wks,u10,v10,opts)
    delete(opts)


;;;;;;;;;;;;;;;;;;Make Plots;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     rawplot = wrf_map_overlays(f,wks,(/contour_O3,vector/),pltres,mpres);

;;;;;;;;;;;;;;;;;;;;;;add polylines;;;;;;;;;;;;;;;;;;;;;;
  shpdir = "/public/home/Mia/NCL-Chinamap-master/cnmap/"

  plres             = True       ; resources for polylines
  plres@gsEdgesOn   = True       ; draw border around polygons
  plres@gsEdgeColor = "black"
  plres@gsLineThicknessF =1.5

;  getvalues rawplot
;    "mpMinLatF" : plres@minlat
;    "mpMaxLatF" : plres@maxlat
;    "mpMinLonF" : plres@minlon
;    "mpMaxLonF" : plres@minlon
;  end  getvalues

  plotshp = gsn_add_shapefile_polylines(wks,rawplot,shpdir+"jiangsu.shp",plres)

  draw(rawplot)
  frame(wks)
  end do  ;End of time loop

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

end


评分

参与人数 1金钱 +5 收起 理由
wuyuanwuhui + 5

查看全部评分

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-10-19 14:40:41 | 显示全部楼层
问题已解决,
pltres@FramePlot                 = False
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表