爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2109|回复: 2

添加shp文件问题

[复制链接]
回帖奖励 45 金钱 回复本帖可获得 5 金钱奖励! 每人限 1 次

新浪微博达人勋

发表于 2022-10-31 13:01:31 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图:
问题概况: 使用NCL添加自己的shp文件,能够运行,没有报错,但就是叠加不了地图。
我看过提问的智慧: 看过
自己思考时长(天): 1

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

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

x
;****************************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"   
load "./WRF_contributed.ncl.test"     ; copied on 4/5/4 from /fs/cgd/data0/shea/nclGSUN.
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"


begin
   ;************************************************
   ; open file and read in data
   ;************************************************

   works = "png"

   first_guess = addfile("/home/fzl/Build_WRF/Domain/WRFDA-Domain/2021081200/wrfinput_d01"+".nc", "r")
   analysis = addfile("/home/fzl/Build_WRF/Domain/WRFDA-Domain/2021081200/wrfvar_output"+".nc", "r")

   ;************************************************
   ; Read vertical coordinate for plot labels
   ;************************************************

   znu   = first_guess->ZNU(0,:)                          ; (Time, bottom_top)

   ;************************************************
   ; Read fields
   ;************************************************
;    Fix the desired level below  
   kl = 1

   var = "U"
   fg = first_guess->U   ;Theta-T0
   an = analysis->U      ;Theta-T0
   plot_data = an - fg
   ;plot_data = an



;   var = "T"
;   fg = first_guess->T ;Theta- 300
;   an = analysis->T    ;Theta- 300
;   plot_data = an - fg
;   plot_data = fg + 300.0

   ;************************************************
   ; create plots  
   ;************************************************

   wks = gsn_open_wks(works, "WRF-VAR_"+var+"_level_"+kl)       ; ps,pdf,x11,ncgm,eps
   gsn_define_colormap(wks ,"BlAqGrYeOrReVi200"); choose colormap
   
   
  
   res                            = True             ; plot mods desired
   res@gsnMaximize                = True
   res@gsnDraw                    = False
   res@gsnFrame                   = False


   
   ;res@cnFillPalette = "OceanLakeLandSnow"
   
   ;set for map

   res@mpFillDrawOrder            = "PostDraw"
   res@mpFillOn                   = True
   res@mpDataSetName              = "Earth..4"
   res@mpDataBaseVersion          = "MediumRes" ; or "Ncarg4_1"
   res@mpAreaMaskingOn            = True
   res@mpMaskAreaSpecifiers       = (/"xizang"/)
   ;res@mpFillAreaSpecifiers       = (/"xizang"/)
   ;res@mpMaskAreaSpecifiers       = (/"China"/)
   res@mpOutlineSpecifiers        = (/"China","China:xizang"/)

   res@mpMinLatF                  = 25.                        
   res@mpMaxLatF                  = 35.
   res@mpMinLonF                  = 90.
   res@mpMaxLonF                  = 110.

   res@mpLandFillColor            = "white"
   res@mpInlandWaterFillColor     = "white"
   res@mpOceanFillColor           = "white"
   res@mpFillBoundarySets         = "NoBoundaries"
   res@mpOutlineBoundarySets      = "NoBoundaries"
   res@mpNationalLineColor        = "black"
   res@mpProvincialLineColor      = "black"
   res@mpGeophysicalLineColor     = "black"
   res@mpNationalLineThicknessF   = 2
   res@mpProvincialLineThicknessF = 2
   ;res@mpOutlineBoundarySets = "AllBoundaries"
   
   WRF_map_c(first_guess,res,0)                           ; set map resources   

   nt                        = 0                ; last time step

   res@gsnSpreadColors       = True             ; use full range of colormap
   res@cnFillOn              = True             ; color plot desired
   res@cnLinesOn             = False            ; turn off contour lines
   res@cnLineLabelsOn        = False            ; turn off contour labels
   res@lbLabelAutoStride     = True             ; let NCL figure lb stride

   

   res@gsnLeftString         = var+"("+kl+")"
   res@gsnRightString        = "2021-08-12 08:00"
   plot                      = gsn_csm_contour_map(wks,plot_data(nt,kl,:,:),res)


   ;--- add shp file boundaries ---
   ShpDir = "/home/fzl/Build_WRF/LIBRARIES/全国各省shp文件/全国各省shp文件/xinjiang_xianjie.shp" ;./cnmap/"
   plres                       = True
   plres@gsLineThicknessF      = 2.0
   plres@gsLineColor           = "red"
   poltshp1 = gsn_add_shapefile_polylines(wks,plot,ShpDir,plres)


   draw(plot)
   frame(wks)




end



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

新浪微博达人勋

发表于 2022-10-31 20:09:31 | 显示全部楼层

回帖奖励 +5 金钱

你要叠加啥样底图
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-11-1 10:41:19 | 显示全部楼层
karenlk 发表于 2022-10-31 20:09
你要叠加啥样底图

您好,我想的是叠加自己的县级底图,然后使用mask函数突出自己想要的区域
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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