- 积分
- 2280
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-9-11
- 最后登录
- 1970-1-1
|
发表于 2012-9-27 10:13:56
|
显示全部楼层
- #--------------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2012-9-26
- # Purpose: Read and plot typhoon data
- # 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)
- #---- Read typhoon data file
- print 'Read typhoon data file...'
- dir = 'F:\\taifeng\\his_typhoon_track'
- list = os.listdir(dir) #列出目录下的所有文件和目录
- for line in list:
- fn = os.path.join(dir,line)
- tf = open(fn)
- tf.readline()
- aline = tf.readline()
- id = aline.split()[1]
- tf.readline()
- aPolyline = PolylineShape()
- plist = List[PointD]()
- 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)
- pLayer.UpdateLegendScheme(LegendType.GraduatedColor, "Wind")
- for legend in pLayer.LegendScheme.LegendBreaks:
- legend.MarkerType = MarkerType.Character
- legend.FontName = "weather"
- legend.CharIndex = 170
- legend.Size = 12
-
- aPolyline.Points = plist
- shapeNum = lLayer.ShapeNum
- if lLayer.EditInsertShape(aPolyline, shapeNum):
- lLayer.EditCellValue("ID", shapeNum, id)
- lLayer.UpdateLegendScheme(LegendType.SingleSymbol, "ID")
- lLayer.LegendScheme.LegendBreaks[0].Size = 2
- mipy.MapDocument.ActiveMapFrame.AddLayer(lLayer)
- mipy.MapDocument.ActiveMapFrame.AddLayer(pLayer)
- print 'Finished!'
复制代码 错误提示:
Create typhoon point layer...
Create typhoon polyline layer...
Read typhoon data file...
Traceback (most recent call last):
File "<string>", line 48, in <module>
发现的我计算机里真没有weather这个字体! |
|