爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 12988|回复: 11

[作图] NCL 只画特定省份,其它省份空白怎么画?

[复制链接]

新浪微博达人勋

发表于 2017-6-6 15:08:49 | 显示全部楼层 |阅读模式

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

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

x
最近学习NCL,想画华南地区站点分布图。但是用NCL画出来之后,不能屏蔽别的省份,这个要怎么修改呢?
我看论坛里面说用res@mpMaskAreaSpecifiers 设置就可以只画出想要的地区,为什么我设置了没有用呢?
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/contrib/cd_string.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/cnmap.ncl"
begin
f=asciiread("/cygdrive/e/fnl/huananzhandian.txt",(/84,3/),"float")
y=new((/84/),"float")
x=new((/84/),"float")
y(:)=f(:,1)
x(:)=f(:,2)
wks=gsn_open_wks("png","/cygdrive/e/fnl/35")
gsn_define_colormap( wks ,"gui_default")  
      
res                         = True            
res@gsnMaximize             = True
res@gsnDraw                 = False
res@gsnFrame                = False
;>--------------------------------------------<
;            set for the map
;>--------------------------------------------<
res@mpMinLatF               = 20.                        
res@mpMaxLatF               = 30.
res@mpMinLonF               = 104.
res@mpMaxLonF               = 120.
res@mpFillOn                = True
res@mpOutlineOn             = False  ; Use outlines from shapefile
res@mpDataBaseVersion       = "MediumRes"
res@mpDataSetName           = "Earth..4"
res@mpAreaMaskingOn         = True
res@mpMaskAreaSpecifiers    = (/"Guandong","Guangxi","Fujian","Jiangxi","Hunan","Guizhou"/)    要画着几个省份
res@mpLandFillColor         = "white"
res@mpInlandWaterFillColor  = "white"
res@mpOceanFillColor        = "white"
res@mpOutlineBoundarySets   = "NoBoundaries"
map=gsn_csm_map(wks, res)
mkres=True
mkres@gsMarkerIndex=2
mkres@gsMarkerSizeF=0.02
mkres@gsMarkerColor="Blue"
gsn_polymarker(wks, map, x, y, mkres)
;>============================================================<
;                      add China map
;>------------------------------------------------------------<
cnres           = True
cnres@china     = True     ;draw china map or not
cnres@river     = False      ;draw changjiang&huanghe or not
cnres@province  = True      ;draw province boundary or not
cnres@nanhai    = False       ;draw nanhai or not
cnres@diqu      = False       ; draw diqujie or not
chinamap = add_china_map(wks,map,cnres)
;>============================================================<
draw(map)
frame(wks)
end
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-1-12 11:56:33 | 显示全部楼层
res@mpFillDrawOrder            = "PostDraw" 亲测有效
密码修改失败请联系微信:mofangbao
回复 支持 2 反对 0

使用道具 举报

新浪微博达人勋

发表于 2017-6-6 17:25:12 | 显示全部楼层
没有太仔细看你的脚本,但是NCL官网里有针对你这个问题的例子http://www.ncl.ucar.edu/Applications/shapefiles.shtml里面的shapefiles_4.ncl就是解决这个问题的,但前提是要先有一个你所需要区域的shp文件,就是先把你所需要的区域抠出来

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

新浪微博达人勋

发表于 2017-6-6 17:37:09 | 显示全部楼层
可能是因为没有res@cnFillDrawOrder = "PreDraw"?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-6-7 11:02:31 | 显示全部楼层
snowie 发表于 2017-6-6 17:37
可能是因为没有res@cnFillDrawOrder = "PreDraw"?

应该不是,之前我也写进去了,后来删除了,这个语句对于画图完全没有影响
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-10 15:44:30 | 显示全部楼层
mpres@mpFillOn&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;= True
mpres@mpFillAreaSpecifiers&nbsp;&nbsp;= (/"Water","其他省份"/)&nbsp;&nbsp;;将海洋和其他省份设置为白色
mpres@mpSpecifiedFillColors = (/"white","white"/)
mpres@mpAreaMaskingOn&nbsp; &nbsp;&nbsp; &nbsp; = True
mpres@mpMaskAreaSpecifiers&nbsp;&nbsp;= "想要的省份"
楼主可以试试看,不过shp文件可以用来做mask的,也挺方便
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-10 15:45:24 | 显示全部楼层
mpres@mpFillOn&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;= True
mpres@mpFillAreaSpecifiers&nbsp;&nbsp;= (/"Water","Guandong"/)&nbsp;&nbsp;;将海洋和广东fill为白色
mpres@mpSpecifiedFillColors = (/"white","white"/)
mpres@mpAreaMaskingOn&nbsp; &nbsp;&nbsp; &nbsp; = True
mpres@mpMaskAreaSpecifiers&nbsp;&nbsp;= "Hainan"
  1. mpres@mpFillOn&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;= True
  2. mpres@mpFillAreaSpecifiers&nbsp;&nbsp;= (/"Water","不要的省份"/)&nbsp;&nbsp;;将海洋和其他省份为白色
  3. mpres@mpSpecifiedFillColors = (/"white","white"/)
  4. mpres@mpAreaMaskingOn&nbsp; &nbsp;&nbsp; &nbsp; = True
  5. mpres@mpMaskAreaSpecifiers&nbsp;&nbsp;= "想要的省份"
复制代码
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-10 15:45:57 | 显示全部楼层
不知道为什么发过去都是这种乱码。。。。。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2020-1-13 09:44:12 | 显示全部楼层
何小肥 发表于 2020-1-12 11:56
res@mpFillDrawOrder            = "PostDraw" 亲测有效

嗯嗯,确实有效,谢谢 但是有个问题是画出来之后省份的边界先模糊了,请问你有这种现象吗,如何解决的?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-1-13 16:12:30 | 显示全部楼层
勇敢的悲伤 发表于 2020-1-13 09:44
嗯嗯,确实有效,谢谢 但是有个问题是画出来之后省份的边界先模糊了,请问你有这种现象吗,如何 ...

我画的省份边界没有模糊呢
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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