爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 14334|回复: 33

[作图] 地形图上加站点

[复制链接]

新浪微博达人勋

发表于 2016-10-27 10:01:29 | 显示全部楼层 |阅读模式

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

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

x
请问各位前辈怎么在地形图上加站点呀
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-10-31 13:24:26 | 显示全部楼层
undef("create_topo_map")
function create_topo_map(wks,minlat,maxlat,minlon,maxlon)
local topo_file, a, elev, res, cmap
begin

  topo_file =  "/home/fanweiwei/NCEP/dbjr/pictures/ht/shuju/ETOPO2v2c_f4.nc"
  a         = addfile(topo_file,"r")
  elev      = a->z({minlat:maxlat},{minlon:maxlon})
printVarSummary(a)
;  elev = where(elev.lt.-100.,elev@_FillValue,elev)
printVarSummary(elev)
elev!0      = "lat"
elev!1      = "lon"

elev&lat =  a->y({minlat:maxlat})
elev&lon =a->x({minlon:maxlon})
elev&lat@units = "degrees_north"  ; 赋予lat方向信息,这个是必须有的
elev&lon@units = "degrees_east"  ; 赋予lon方向信息,这个是必须有的
printVarSummary(elev)
  cmap = read_colormap_file("MPL_BrBG")


  res                    = True

  res@gsnMaximize        = True         ; maximize plot in frame

  res@gsnDraw            = False
  res@gsnFrame           = False

  res@cnFillOn           = True         ; turn on contour fill
; res@cnFillMode         = "MeshFill"   ; for faster draw
  res@cnFillPalette      = cmap
   res@cnFillMode         = "RasterFill"   ; for faster draw
  res@cnLinesOn          = False        ; turn off contour lines
  res@cnLineLabelsOn     = False        ; turn off line labels
  res@cnInfoLabelOn      = False        ; turn off info label
  res@lbBoxLinesOn       = False        ; turn off labelbar box lines
  res@lbTitleString      = "elevation (meters)"    ; add a labelbar title
  res@lbTitleFontHeightF = 0.015
  res@lbTitlePosition    = "Bottom"
  res@pmLabelBarOrthogonalPosF = 0.15

;---Pick "nice" contour levels
  mnmxint = nice_mnmxintvl( min(elev), max(elev), 18, False)
  res@cnLevelSelectionMode = "ManualLevels"
  res@cnMinLevelValF       = mnmxint(0)
  res@cnMaxLevelValF       = mnmxint(1)
  res@cnLevelSpacingF      = 50   ; Increase the number of levels
                                             ; by choosing a smaller spacing.
;---Zoom in on map
  res@mpMinLatF            = minlat
  res@mpMaxLatF            = maxlat
  res@mpMinLonF            = minlon
  res@mpMaxLonF            = maxlon
  res@mpCenterLonF         = (res@mpMinLonF + res@mpMaxLonF) / 2.

  res@mpDataBaseVersion    = "MediumRes"

  res@mpFillOn             = False
  res@mpOutlineOn          = True
  res@mpOutlineBoundarySets = "AllBoundaries"
  res@gsnAddCyclic         = False           ; don't add longitude cyclic point

  res@tiMainString          = "Rivers of Colorado"
  res@gsnLeftString         = ""
  res@gsnRightString        = ""
  res@pmTickMarkDisplayMode = "Always"
  res@pmTitleZone           = 4              ; move main title down a little
;  res@mpMaskAreaSpecifiers = (/"China:states"/)
;res@mpMaskAreaSpecifiers =(/"China:states","Taiwan"/)
res@mpDataSetName         = "Earth..4"   ; This new database contains
;---Create map and return it.
  plot = gsn_csm_contour_map(wks,elev,res)
  return(plot)
end


begin
  wks = gsn_open_wks("png","topo")          ; send graphics to PNG file

;---Lat/lon limits for Colorado
  minlat   = 25
  maxlat   = 40
  minlon   = 70
  maxlon   = 105

;---Create topo map of Colorado
  topo_map = create_topo_map(wks,minlat,maxlat,minlon,maxlon)
  station             = asciiread("/home/fanweiwei/NCEP/dbjr/pictures/ht/shuju/zhandian.txt",(/61,2/),"float")  

lat1  = station(:,0)
  lon1   = station(:,1)
  pmres                 = True                       

  pmres@minlat           = minlat
  pmres@maxlat           = maxlat
  pmres@minlon           = minlon
  pmres@maxlon           = maxlon


pmres@gsMarkerIndex    = 16
  pmres@gsMarkerSizeF    = 0.01
  pmres@gsMarkerColor    = "black"
   ;
d=gsn_add_polymarker(wks,topo_map,lon1,lat1,pmres)

;---Drawing the topo map will also draw shapefile outlines
  draw(topo_map)
  frame(wks)
end
密码修改失败请联系微信:mofangbao
回复 支持 2 反对 0

使用道具 举报

新浪微博达人勋

发表于 2016-10-27 13:24:48 | 显示全部楼层
你这个问题叫人如何回答?一点描述都没有?!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-10-27 20:57:54 | 显示全部楼层
handsoman22 发表于 2016-10-27 13:24
你这个问题叫人如何回答?一点描述都没有?!


                               
登录/注册后可看大图

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

新浪微博达人勋

 楼主| 发表于 2016-10-27 20:58:19 | 显示全部楼层
您好就是这种图,加上站点的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-10-28 16:16:43 | 显示全部楼层
gsn_add_polymarker
gsn_add_text
用这两个。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-10-28 21:30:20 | 显示全部楼层
zly4814624 发表于 2016-10-28 16:16
gsn_add_polymarker
gsn_add_text
用这两个。

您好我用了那个 gsn_add_polymarker
好像不管用方便帮我看看原因吗
谢谢了
undef("create_topo_map")
function create_topo_map(wks,minlat,maxlat,minlon,maxlon)
local topo_file, a, elev, res, cmap
begin
;---Subsetting the data is not necessary, but it will make plotting go much faster.
  topo_file =  "/home/NCEP/dbjr/pictures/ht/shuju/ETOPO2v2c_f4.nc"
  a         = addfile(topo_file,"r")
  elev      = a->z

;---Will use this later for coloring the contours
  cmap = read_colormap_file("OceanLakeLandSnow")

;---Set some resources for contouring and mapping
  res                    = True

  res@gsnMaximize        = True         ; maximize plot in frame

  res@gsnDraw            = False
  res@gsnFrame           = False

  res@cnFillOn           = True         ; turn on contour fill
  ;res@cnFillMode         = "MeshFill"   ; for faster draw
  res@cnFillPalette      = cmap(2:,:)

  res@cnLinesOn          = False        ; turn off contour lines
  res@cnLineLabelsOn     = False        ; turn off line labels
  res@cnInfoLabelOn      = False        ; turn off info label
  res@lbBoxLinesOn       = False        ; turn off labelbar box lines
  res@lbTitleString      = "elevation (meters)"    ; add a labelbar title
  res@lbTitleFontHeightF = 0.015
  res@lbTitlePosition    = "Bottom"
  res@pmLabelBarOrthogonalPosF = 0.15

;---Pick "nice" contour levels
  mnmxint = nice_mnmxintvl( min(elev), max(elev), 18, False)
  res@cnLevelSelectionMode = "ManualLevels"
  res@cnMinLevelValF       = mnmxint(0)
  res@cnMaxLevelValF       = mnmxint(1)
  res@cnLevelSpacingF      = mnmxint(2)/8.   ; Increase the number of levels
                                             ; by choosing a smaller spacing.
;---Zoom in on map
  res@mpMinLatF            = minlat
  res@mpMaxLatF            = maxlat
  res@mpMinLonF            = minlon
  res@mpMaxLonF            = maxlon
  res@mpCenterLonF         = (res@mpMinLonF + res@mpMaxLonF) / 2.

  res@mpDataBaseVersion    = "MediumRes"

  res@mpFillOn             = False
  res@mpOutlineOn          = True
  res@mpOutlineBoundarySets = "AllBoundaries"
  res@gsnAddCyclic         = False           ; don't add longitude cyclic point

  res@tiMainString          = "Rivers of Colorado"
  res@gsnLeftString         = ""
  res@gsnRightString        = ""
  res@pmTickMarkDisplayMode = "Always"
  res@pmTitleZone           = 4              ; move main title down a little

;---Create map and return it.
  plot = gsn_csm_contour_map(wks,elev,res)
  return(plot)
end

;----------------------------------------------------------------------
; Main code
;----------------------------------------------------------------------
begin
  wks = gsn_open_wks("png","topo")          ; send graphics to PNG file

;---Lat/lon limits for Colorado
  minlat   =25
  maxlat   = 40
  minlon   = 75
  maxlon   = 105

;---Create topo map of Colorado
  topo_map = create_topo_map(wks,minlat,maxlat,minlon,maxlon)

;---Attach rivers from shapefile
  station             = asciiread("/home/NCEP/dbjr/pictures/ht/shuju/zhandian.txt",(/57,2/),"float")  
  lat   = station(:,0)
   lon   = station(:,1)
printVarSummary(lat)

  pmres                 = True                       
pmres@gsMarkerIndex    = 12
  pmres@gsMarkerSizeF    = 0.02
  pmres@gsMarkerColor    = "yellow"
   
  plots=gsn_add_polymarker(wks,topo_map,lat,lon,pmres)

draw(topo_map)
  frame(wks)

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

新浪微博达人勋

发表于 2016-10-30 16:13:33 | 显示全部楼层
有报错么。报错是什么。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-10-31 07:51:29 | 显示全部楼层
zly4814624 发表于 2016-10-30 16:13
有报错么。报错是什么。

您好,报错是这个
(0)        check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all.
(0)        A valid latitude coordinate array should have a 'units' attribute equal to one of the following values:
(0)            'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)        check_for_lon_coord: Warning: Data either does not contain a valid longitude coordinate array or doesn't contain one at all.
(0)        A valid longitude coordinate array should have a 'units' attribute equal to one of the following values:
(0)            'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'

Variable: lat
Type: float
Total Size: 228 bytes
            57 values
Number of Dimensions: 1
Dimensions and sizes:        [57]
Coordinates:
Number Of Attributes: 2
  units :        degrees_north
  _FillValue :        9.96921e+36
fatal:ContourPlotDraw: Workspace reallocation would exceed maximum size 100000000
fatal:ContourPlotDraw: draw error
fatal:ContourPlotDraw: draw error
fatal:PlotManagerDraw: error in plot draw
fatal:_NhlPlotManagerDraw: Draw error
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-10-31 08:33:47 | 显示全部楼层
Data either does not contain a valid latitude coordinate array or doesn't contain one at all
数据的经纬度设置是不是有问题。再去好好检查一下吧。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-10-31 09:17:15 | 显示全部楼层
zly4814624 发表于 2016-10-31 08:33
Data either does not contain a valid latitude coordinate array or doesn't contain one at all
数据的 ...

嗯嗯好的谢谢你
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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