- 积分
- 71
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-9-1
- 最后登录
- 1970-1-1
|
发表于 2016-2-17 08:59:45
|
显示全部楼层
最终目的是使用站点数据画南部几个省的年降水分布
使用meteoinfo制作了广东省的shape文件,没有问题,可以画出广东省的年降水分布- 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/csm/contributed.ncl"
- ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
- load "./shapefile_mask_data.ncl"
- begin
- fili = "./nan.txt"
- arg = asciiread(fili,-1,"string")
- count = str_fields_count(arg," ")
- line = dimsizes(arg)
- data = new( (/line,count(0)-1/), string)
- do j = 0, line-1
- do i = 0, count(0)-2
- data(j,i) = str_get_field(arg(j),i+1," ")
- end do
- end do
- ;print(data)
- station = stringtofloat(data(:,0))
- lat = stringtofloat(data(:,1))
- lon = stringtofloat(data(:,2))
- tem = stringtofloat(data(:,3))
- tem_h = stringtofloat(data(:,4))
- tem_l = stringtofloat(data(:,5)) ;count of rainfall in dali
- pa = stringtofloat(data(:,6))
- rain20 = stringtofloat(data(:,7))
- rn = stringtofloat(data(:,8))*365
- ;wind = stringtofloat(data(:,9))
- ;range of lat(24.6,26.8) and lon(98.8,101.1)
- minlat = 18.0
- maxlat = 31.0
- minlon = 97.0
- maxlon = 118.0
- olon = new(211,"float")
- olat = new(131,"float")
- data1 = new((/131,211/),"float")
- do i=0,210
- olon(i) = minlon+i*0.1
- end do
- do l=0,130
- olat(l) = minlat+l*0.1
- end do
- olon!0 = "lon"
- olon@long_name = "lon"
- olon@units = "degrees-east"
- olon&lon = olon
- olat!0 = "lat"
- olat@long_name = "lat"
- olat@units = "degrees_north"
- olat&lat = olat
- lon@units = olon@units
- lat@units = olat@units
- rn@_FillValue = -9999.0
- ;obj_anal_ic_deprecated--Iterative correction objective analysis (Cressman, Barnes)
- rscan = (/1,.9,.8,.7,.6,.4,.1/)
- data1 = obj_anal_ic_deprecated(lon,lat,rn,olon,olat,rscan, False)
- shp_filename = "./nanbu/test-nan.shp"
- ;county = new(line,"string")
- ;county = (/"Yunlong","Yangbi","Yongping","Dali","Binchuan","Midu",\
- ; "Xiangyun","Weishan","Jianchuan","Eryuan","Heqing","Nanjian"/)
- data_mask = shapefile_mask_data(data1,shp_filename,True)
- wks = gsn_open_wks("X11","rain_count_nb")
- gsn_define_colormap(wks,"BlAqGrYeOrRe")
- res = True
- res@gsnDraw = False
- res@gsnFrame = False
- res@gsnAddCyclic = False
- ;res@mpDataSetName = "Earth..4"
- ;res@mpDataBaseVersion = "MediumRes"
- ;res@mpOutlineOn = True
- res@mpMinLatF = minlat
- res@mpMaxLatF = maxlat
- res@mpMinLonF = minlon
- res@mpMaxLonF = maxlon
- res@mpGeophysicalLineThicknessF= 2.
- res@mpNationalLineThicknessF= 2.
- ;res@mpLimitMode = "LatLon"
- ;res@mpLambertParallel1F = .001
- ;res@mpLambertParallel2F = 89.999
- res@cnFillOn = True
- res@cnLinesOn = False
- res@cnLineLabelsOn = False
-
- res@pmTickMarkDisplayMode = "Always"
- map_mask = gsn_csm_contour_map(wks,data_mask,res)
- lnres = True
- lnres@gsLineColor = "black"
- lnres@gsLineThicknessF = 2.0
- line_mask = gsn_add_shapefile_polylines(wks, map_mask, shp_filename, lnres)
- draw(map_mask)
- ;tres =True
- ;tres@txFontHeightF = 0.01
- ;do i = 0, line-1
- ; gsn_text(wks,map_mask,county(i),lon(i),lat(i),tres)
- ;end do
- frame(wks)
- end
复制代码 。
可是如果使用meteoinfo制作了广东+广西+云南+海南几个省的shape文件,同样的NCL脚背就会报错:
ERROR 10:Pointer 'hGeom' is NULL in 'OGR_G_GetGeometryCount'.
ERROR 10:Pointer 'hGeom' is NULL in 'OGR_G_GetPointCount'.
……
附上脚本 |
|