- 积分
- 4182
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-27
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2011-12-2 11:12:17
|
显示全部楼层
效果图如下,脚本程序同样附上。
- # 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=84")
- #---- 按照经纬度范围缩放地图
- myApp.ZoomLonLat(76,94,35,50)
- #---- 设置屏蔽图层(只绘制中国境内图形)
- myApp.SetMaskout("china.shp")
- #---- 站点数据插值为格点数据的设置
- myApp.SetInterpolation(60,140,-20,60,160,160,"IDW_Radius",1,1)
- #---- 设置图例文件
- #myApp.SetLegendScheme("..\\Legend\\tem.lgs")
-
- #---- 设置DefalutLayoutMap(图层显示)
- myApp.MapLayout.DefaultLayoutMap.DrawGridLine = True
- myApp.MapLayout.DefaultLayoutMap.DrawNeatLine = True
- myApp.MapLayout.DefaultLayoutMap.Left = 10
- myApp.MapLayout.DefaultLayoutMap.Top = 10
- myApp.MapLayout.DefaultLayoutMap.Width = 620
- myApp.MapLayout.DefaultLayoutMap.Height = 450
-
- #---- 设置DefaultTitle(图形标题)
- myApp.MapLayout.DefaultTitle.SetFont("黑体", 12)
- myApp.MapLayout.DefaultTitle.Top = 30
- 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 = 640
- myApp.MapLayout.DefaultLegend.Top = 150
-
- #---- 设置起始结束时间
- sTime = DateTime.Parse("2011-8-3 18:00")
- eTime = DateTime.Parse("2011-8-3 18:00")
-
- #---- 循环
- while sTime <= eTime:
- myApp.RemoveDataLayers()
- inFile = sTime.ToString("yyMMddHH") + ".000"
- print inFile
- #---- 打开MICAPS数据文件
- myApp.OpenMICAPSData("..\\Sample\\aws\" + inFile)
- #---- 设置绘图类型为shaded
- myApp.SetDrawType("Shaded")
- myApp.Display("Temperature")
- myApp.SetDrawType("Barb")
- myApp.MeteoDataInfo.MeteoUVStr.IsUV = False
- myApp.Display("WindDirection","WindSpeed")
- print "Display finished"
- #---- 调整图层顺序(以避免压盖)
- myApp.MoveLayerToTop("bou2_4p.shp")
- #myApp.MoveLayerToTop("bou1_4l.shp")
- myApp.MoveLayerToTop("res1_4m.shp")
- #---- 设置标题名称
- title = " 新疆区域温度分布图 (" + sTime.ToString("yyyy-MM-dd HH:00") + ")"
- myApp.SetTitle(title)
- #---- 设置图例名称
- myApp.MapLayout.DefaultLegend.Title = "温度(℃)"
- #---- 绘制图形
- myApp.MapLayout.PaintGraphics()
- #---- 输出图形为文件
- outFile = "tem_" + sTime.ToString("yyyyMMddHH") + ".png"
- print outFile
- myApp.SaveFigure("E:\" + outFile)
- #---- 删除6小时降水量图层
- if sTime < eTime:
- myApp.RemoveLastLayer()
- #---- 时间加6小时
- sTime = sTime.AddHours(1)
- #---- 显示程序窗体(只是为了看效果,自动运行时不需要)
- Application.Run(myApp)
复制代码 |
|