- 积分
- 400
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-29
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2011-7-11 09:25:35
|
显示全部楼层
# This Python file uses the following encoding: GB2312
#---- 引入类库
import clr
clr.AddReferenceByPartialName("System")
clr.AddReferenceByPartialName("System.Windows.Forms")
clr.AddReferenceByPartialName("System.Drawing")
from System import *
from System.Windows.Forms import *
from System.Drawing import *
clr.AddReference("MeteoInfoC.dll")
from MeteoInfoC import *
from MeteoInfoC.Layout import *
from MeteoInfoC.Data import *
#---- 创建MIApp类的对象
myApp = MIApp()
#---- 添加图层
myApp.OpenLayer(".\\Map\\bou2_4p.shp")
#---- 设置图层渲染
myApp.SetLegendBreak("bou2_4p.shp",0,Color.Yellow,Color.Gray,1,True,False,True)
myApp.OpenLayer(".\\Map\\bou1_4l.shp")
myApp.SetLegendBreak("bou1_4l.shp",0,Color.Blue)
myApp.OpenLayer(".\\Map\\china.shp")
myApp.SetLayerVisible("china.shp", False)
myApp.OpenLayer(".\\Map\\res1_4m.shp")
myApp.SetLegendBreak("res1_4m.shp",0,5,Color.Red,Color.Black,True,True,True)
#---- 获取矢量图层对象,并设置标注
aLayer = myApp.GetVectorLayer("res1_4m.shp")
aLayer.LabelSet.FieldName = "NAME";
aLayer.LabelSet.LabelFont = Font("楷体", 10);
aLayer.LabelSet.Offset = 15;
aLayer.AddLabels();
#---- Lambert投影
myApp.ProjectLayers("+proj=lcc+lat_1=25+lat_2=47+lon_0=105")
#---- 按照经纬度范围缩放地图
myApp.ZoomLonLat(100,125,20,35)
#---- 设置屏蔽图层(只绘制中国境内图形)
myApp.SetMaskout("china.shp")
#---- 设置绘图类型为shaded
myApp.SetDrawType("shaded")
#---- 站点数据插值为格点数据的设置
myApp.SetInterpolation(60,140,-20,60,160,160,"IDW_Radius",1,1)
#---- 设置图例文件
myApp.SetLegendScheme(".\\Legend\\rain1.lgs")
#---- 设置DefalutLayoutMap(图层显示)
myApp.MapLayout.DefaultLayoutMap.DrawGridLine = False
myApp.MapLayout.DefaultLayoutMap.DrawNeatLine = False
myApp.MapLayout.DefaultLayoutMap.Left = 10
myApp.MapLayout.DefaultLayoutMap.Top = 10
myApp.MapLayout.DefaultLayoutMap.Width = 620
myApp.MapLayout.DefaultLayoutMap.Height = 450
#---- 设置DefaultIllustration(插图,这里是南海脚图)
#myApp.MapLayout.DefaultIllustration.Visible = True
#myApp.MapLayout.DefaultIllustration.Left = 40
#myApp.MapLayout.DefaultIllustration.Top = 350
#myApp.MapLayout.DefaultIllustration.Width = 85
#myApp.MapLayout.DefaultIllustration.Height = 109
#---- 设置DefaultTitle(图形标题)
myApp.MapLayout.DefaultTitle.SetFont("黑体", 12)
myApp.MapLayout.DefaultTitle.Top = 40
myApp.MapLayout.DefaultTitle.Left = 80
#---- 设置DefaultLegend(图例)
myApp.MapLayout.DefaultLegend.LegendStyle = LegendStyleEnum.Normal
myApp.MapLayout.DefaultLegend.DrawNeatLine = False
myApp.MapLayout.DefaultLegend.Title = "降水量(毫米)"
myApp.MapLayout.DefaultLegend.BackColor = Color.White
myApp.MapLayout.DefaultLegend.Font = Font("Arial", 8)
myApp.MapLayout.DefaultLegend.Left = 575
myApp.MapLayout.DefaultLegend.Top = 250
#---- 设置起始结束时间
sTime = DateTime.Parse("2009-02-14 08:00")
eTime = DateTime.Parse("2009-03-08 20:00")
aTime = sTime.AddHours(-6)
stData = StationData()
i = 1
#---- 循环
while sTime <= eTime:
myApp.RemoveDataLayers()
inFile = sTime.ToString("yyMMddHH") + ".000"
print inFile
#---- 打开MICAPS数据文件
myApp.OpenMICAPSData(".\\Sample\\MICAPS\\" + inFile)
#---- 获取累计降水站点数据
if i == 1:
stData = myApp.GetStationData("Precipitation6h")
else:
stData = stData + myApp.GetStationData("Precipitation6h")
#---- 时间加6小时
sTime = sTime.AddHours(6)
i = i + 1
#---- 绘制累计降水图层
myApp.Display(stData)
#---- 调整图层顺序(以避免压盖)
myApp.MoveLayerToTop("bou2_4p.shp")
myApp.MoveLayerToTop("bou1_4l.shp")
myApp.MoveLayerToTop("res1_4m.shp")
#---- 设置标题名称
title = " 全国降水量实况图\n" + aTime.ToString("yyyy年MM月dd日HH时") + " - " + eTime.ToString("yyyy年MM月dd日HH时")
myApp.SetTitle(title)
#---- 设置图例名称
myApp.MapLayout.DefaultLegend.Title = "降水量(毫米)"
#---- 绘制图形
myApp.MapLayout.PaintGraphics()
#---- 输出图形为文件
outFile = "Prec_" + sTime.ToString("yyyyMMddHH") + "-" + eTime.ToString("yyyyMMddHH") + ".png"
print outFile
myApp.SaveFigure("G:\\" + outFile)
|
|