NCL绘制中国地图

现在正在学NCL,用它绘制了一样中国地图

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin

;---Area to zoom in on.
  minlat = 17 
  maxlat = 55
  minlon = 72
  maxlon = 136

  wks  = gsn_open_wks("png","China_Map")

    mpres                         = True
    mpres@gsnMaximize             = True
    mpres@gsnDraw                 = False
    mpres@gsnFrame                = False
    
	mpres@mpDataBaseVersion     = "LowRes"
	mpres@mpOutlineOn           = False 

    mpres@mpLandFillColor         = "white"
    mpres@mpOceanFillColor        = "white"
    mpres@mpInlandWaterFillColor  = "white"

;---Zoom in on area of interest
    mpres@mpLimitMode           = "LatLon"
    mpres@mpMinLatF               = minlat 
    mpres@mpMaxLatF               = maxlat 
    mpres@mpMinLonF               = minlon
    mpres@mpMaxLonF               = maxlon

  map_plot = gsn_csm_map(wks,mpres)   ; Create map, but don't draw it yet.
;****************************************************************************
; sections for shapefiles
;****************************************************************************
;---适合中国的国界地图
  shpfn1="bou1_4l.shp"
  lnres        = True
  lnres@minlat = minlat
  lnres@maxlat = maxlat
  lnres@minlon = minlon
  lnres@maxlon = maxlon
  shp_plot1     = gsn_add_shapefile_polylines(wks,map_plot,shpfn1,lnres)
  
 ;---加上省级区域地图 
  shpfn2="bou2_4p.shp"
  gres        = True
  gres@minlat = minlat
  gres@maxlat = maxlat
  gres@minlon = minlon
  gres@maxlon = maxlon
  gres@gsEdgesOn   =True
  gres@gsEdgeColor   ="blue"
  shp_plot2     = gsn_add_shapefile_polygons(wks,map_plot,shpfn2,gres)
  
 ;---加上一级河流 
  shpfn3="hyd1_4l.shp"
  lnres3        = True
  lnres3@minlat = minlat
  lnres3@maxlat = maxlat
  lnres3@minlon = minlon
  lnres3@maxlon = maxlon
  shp_plot3     = gsn_add_shapefile_polylines(wks,map_plot,shpfn3,lnres3)

  maximize_output(wks,False)

end
效果如下:


  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
绘制降水分布图,您可以使用NCL提供的气象数据集和相关函数。以下是一个示例,演示如何使用NCL绘制降水分布图: ```ncl begin ; 创建一个新的图形窗口 wks = gsn_open_wks("x11","precipitation_map") ; 读取气象数据集(这里使用NCL自带的气象数据集,您也可以使用自己的数据) load "$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc" ; 提取所需变量的值和坐标 prcp = uv300@prcp ; 降水量 lon = uv300@lon ; 经度 lat = uv300@lat ; 纬度 ; 创建一个填色图(降水分布图) res = True res@gsnMaximize = True ; 最大化绘图区域 res@gsnDraw = False ; 不自动绘制图形 res@gsnFrame = False ; 不绘制外边框 res@cnFillOn = True ; 打开填充色 res@cnLinesOn = False ; 关闭等值线 res@cnLevelSelectionMode = "Manual" ; 手动设置填色级别 res@cnMinLevelValF = 0 ; 最小填色级别值 res@cnMaxLevelValF = 100 ; 最大填色级别值 res@cnLevelSpacingF = 10 ; 填色级别的间隔 res@cnFillPalette = "precip_11lev" ; 使用预定义的填色方案 plot = gsn_csm_contour_map(wks, prcp, res) ; 绘制降水分布图 ; 添加标题和轴标签 resources = True resources@gsTitleString = "Precipitation Map" resources@gsXAxisLabelString = "Longitude" resources@gsYAxisLabelString = "Latitude" ; 使用自定义的资源绘制图形 gsn_axis(wks, resources) gsn_text_ndc(wks, "Created with NCL", 0.15, 0.05, 0.03) ; 显示图形 draw(plot) end ``` 上述示例中,我们首先创建一个新的图形窗口,然后使用`load`函数读取NCL自带的气象数据集(`uv300.nc`文件)。接下来,我们提取了所需的变量(降水量)以及经纬度坐标。 然后,我们创建了一个填色图,并使用`gsn_csm_contour_map`函数绘制降水分布图。我们设置了一些自定义的资源参数,如最大最小填色级别值、填色间隔等,并使用预定义的填色方案。 最后,我们添加了标题和轴标签,并使用`gsn_axis`函数和`gsn_text_ndc`函数绘制图形。 请注意,上述示例中使用了NCL自带的气象数据集,您也可以替换为您自己的数据集。此外,您可以根据需要调整资源参数和自定义图形的样式。希望这个示例对您有所帮助!
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值