- 积分
- 1029
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-2-11
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
用meteoinfo出台风路径图的时候发现出错,用原始数据就可以,当用自己的数据就不行,但是搞不懂什么原因
附上王老师的程序一枚,http://bbs.06climate.com/forum.php?mod=viewthread&tid=47734
#--------------------------------------------------------
# Author: Yaqiang Wang
# Date: 2012-11-18
# Purpose: Read and plot typhoon data - polyline with different color
# Note: Sample
#-----------------------------------------------------------
#---- Import clr and classes
import clr
clr.AddReferenceByPartialName("System")
clr.AddReferenceByPartialName("System.Drawing")
from System import *
from System.Drawing import *
from System.Collections.Generic import *
clr.AddReference("MeteoInfoC.dll")
from MeteoInfoC import *
from MeteoInfoC.Data.MapData import *
from MeteoInfoC.Geoprocess import *
from MeteoInfoC.Layer import *
from MeteoInfoC.Shape import *
from MeteoInfoC.Legend import *
from MeteoInfoC.Drawing import *
import os.path
#---- Create a point and line layers to plot typhoon pathway
print 'Create typhoon point layer...'
pLayer = VectorLayer(ShapeTypes.Point)
pLayer.LayerName = "Typhoon_Point"
pLayer.Visible = True
pLayer.EditAddField("Time", String)
pLayer.EditAddField("Wind", Int32)
pLayer.EditAddField("Status", String)
print 'Create typhoon polyline layer...'
lLayer = VectorLayer(ShapeTypes.Polyline)
lLayer.LayerName = "Typhoon_Line"
lLayer.Visible = True
lLayer.EditAddField("ID", String)
lLayer.EditAddField("Time", String)
lLayer.EditAddField("Wind", Int32)
lLayer.EditAddField("Status", String)
#---- Read typhoon data file
print 'Read typhoon data file...'
fn = "e:\\201702merbok.dat"
tf = open(fn)
tf.readline()
aline = tf.readline()
id = aline.split()[1]
tf.readline()
plist = List[PointD]()
i = 0
for aline in tf:
print aline
datalist = aline.split()
lat = float(datalist[1])
lon = float(datalist[2])
t = datalist[3]
wind = int(datalist[4])
stat = datalist[6]
if len(datalist) == 8:
stat = stat + ' ' + datalist[7]
aPS = PointShape()
aPoint = PointD(lon, lat)
aPS.Point = aPoint
plist.Add(aPoint)
shapeNum = pLayer.ShapeNum
if pLayer.EditInsertShape(aPS, shapeNum):
pLayer.EditCellValue("Time", shapeNum, t)
pLayer.EditCellValue("Wind", shapeNum, wind)
pLayer.EditCellValue("Status", shapeNum, stat)
if plist.Count > 1:
aPolyline = PolylineShape()
aPolyline.Points = plist
shapeNum = lLayer.ShapeNum
if lLayer.EditInsertShape(aPolyline, shapeNum):
lLayer.EditCellValue("ID", shapeNum, id)
lLayer.EditCellValue("Time", shapeNum, t)
lLayer.EditCellValue("Wind", shapeNum, wind)
lLayer.EditCellValue("Status", shapeNum, stat)
aPoint = PointD(plist[1].X, plist[1].Y)
plist = List[PointD]()
plist.Add(aPoint)
i += 1
pLayer.UpdateLegendScheme(LegendType.GraduatedColor, "Wind")
for legend in pLayer.LegendScheme.LegendBreaks:
legend.MarkerType = MarkerType.Character
legend.FontName = "Weather"
legend.CharIndex = 170
legend.Size = 12
lLayer.UpdateLegendScheme(LegendType.GraduatedColor, "Wind")
for legend in lLayer.LegendScheme.LegendBreaks:
legend.Size = 2
mipy.MapDocument.ActiveMapFrame.AddLayer(lLayer)
mipy.MapDocument.ActiveMapFrame.AddLayer(pLayer)
print 'Finished!'
|
|