- 积分
- 102
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-8-22
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2014-8-15 11:21:28
|
显示全部楼层
本帖最后由 La_respiration 于 2014-8-15 11:23 编辑
# coding=utf-8
#---- 引入类库
import clr
import time
import datetime
import System
clr.AddReferenceByPartialName("System")
clr.AddReferenceByPartialName("System.Windows.Forms")
clr.AddReferenceByPartialName("System.Drawing")
clr.AddReference('System.Data')
from System.Data import *
from System import *
from System.Windows.Forms import *
from System.Drawing import *
clr.AddReference("MeteoInfoC.dll")
from MeteoInfoC import *
from MeteoInfoC.Data.MapData import *
from MeteoInfoC.Data import *
from MeteoInfoC.Data.MeteoData import *
from MeteoInfoC.Layout import *
from MeteoInfoC.Legend import *
from MeteoInfoC.Projections import *
from MeteoInfoC.Shape import *
dt=DateTime.Now
if System.DateTime.Now.Hour>8 :
print System.DateTime.Now.Hour
else:
print "hello world"
print dt.AddDays(-1).ToString()
#---- 设置路径变量
#print myarr
BaseDir = "d:\\app\\"
MapDir = BaseDir + "Map\\"
LegendDir = BaseDir + "Legend\\"
DataDir = BaseDir + "Sample\\MICAPS\\"
#---- 打开图层
lnLayer = MapDataManage.OpenLayer(MapDir + "ln.shp")
lb = lnLayer.LegendScheme.LegendBreaks[0]
lb.Color = Color.Yellow
lb.OutlineColor = Color.Gray
lb.OutlineSize = 1
lb.DrawFill = False
countyLayer = MapDataManage.OpenLayer(MapDir + "countyname.shp")
lb = countyLayer.LegendScheme.LegendBreaks[0]
lb.Color = Color.Gray
countynameLayer = MapDataManage.OpenLayer(MapDir + "county.shp")
lb = countynameLayer.LegendScheme.LegendBreaks[0]
lb.Color = Color.Gray
lb.OutlineColor = Color.Red
lb.Size = 0
countynameLayer.LabelSet.FieldName = "NAME";
countynameLayer.LabelSet.LabelFont = Font("楷体", 12);
countynameLayer.LabelSet.LabelColor=Color.Red
countynameLayer.LabelSet.YOffset = 15;
countynameLayer.AddLabels();
#---- 创建MIApp类的对象
myApp = MIApp()
mapLayout = myApp.MapLayout
layoutMap = mapLayout.ActiveLayoutMap
mapFrame = layoutMap.MapFrame
mapView = mapFrame.MapView
#----设置Layout
mapLayout.SetPaperSize(650, 800)
#---- 添加图层
mapFrame.AddLayer(lnLayer)
mapFrame.AddLayer(countyLayer)
mapFrame.AddLayer(countynameLayer)
#---- mercator投影
projInfo = ProjectionInfo(" +proj=lonlat +ellps=WGS84 +datum=WGS84 +no_defs= +k=1")
mapView.ProjectLayers(projInfo)
#---- 按照经纬度范围缩放地图
mapView.ZoomToExtentLonLat(119,125.652801513672,37.6575018310547,43.77)
#---- 设置屏蔽图层(只绘制辽宁省内图形)
mapView.MaskOut.SetMaskLayer = True
mapView.MaskOut.MaskLayer = lnLayer.LayerName
#---- 设置ActiveLayoutMap(图层显示)
layoutMap.DrawGridLine = False
layoutMap.DrawNeatLine = False
layoutMap.DrawGridLabel = False
layoutMap.DrawGridTickLine = False
layoutMap.Left = -40
layoutMap.Top = -20
layoutMap.Width = 900
layoutMap.Height = 750
#---- 设置图形标题
#---- 220=left ,50=top
aText = mapLayout.AddText("Temp",150,30,"黑体",16)
#print time.strftime('%H')
#---- 设置图例
aLegend = mapLayout.AddLegend(10,110)
aLegend.LegendStyle = LegendStyles.Bar_Vertical
aLegend.DrawNeatLine = False
#aLegend.Height=100
#aLegend.Width=80
aLegend.Title = "降水量(毫米)"
aLegend.BackColor = Color.White
aLegend.Font = Font("微软雅黑", 12)
#---- 站点数据插值为格点数据的设置
interpSet = InterpolationSetting(118.9417,125.6528,38.7675,44.0831,500,500,"IDW_Radius",0.5,1)
#---- 设置图例
ls = LegendScheme(ShapeTypes.Polygon)
ls.ImportFromXMLFile(LegendDir + "1H.lgs")
ls2 = LegendScheme(ShapeTypes.Point)
ls2.ImportFromXMLFile(LegendDir + "null.lgs")
#---- 设置MeteoDataInfo
mid = MeteoDataInfo()
#---- 打开站点数据文件
mid.OpenLonLatData("d:\\data.txt")
#---- 获取降水量站点数据
stData = mid.GetStationData("Precipitation")
nameData=mid.GetStationInfoData()
#---- 将站点数据差值为格点数据
gData = DrawMeteoData.InterpolateData(stData, interpSet)
#---- 生成降水量图层
rainLayer = DrawMeteoData.CreateShadedLayer(gData, ls, "Precipitation", "Rain")
#templayer = DrawMeteoData.CreateContourLayer(gData,ls2,"Precipitation", "Rain2")
templayer= DrawMeteoData.CreateSTInfoLayer(nameData,ls2,"Precipitation")
templayer.LabelSet.DrawLabels = True
templayer.LabelSet.DrawShadow = False
templayer.LabelSet.ShadowColor = Color.White
templayer.LabelSet.YOffset = 3
templayer.LabelSet.LabelColor = Color.Black
templayer.LabelSet.FieldName = "Precipitation"
templayer.LabelSet.ColorByLegend = True
templayer.LabelSet.DynamicContourLabel = True
templayer.LabelSet.LabelFont=Font("Arial",8)
templayer.AddLabels();
#rainLayer.LabelSet.FieldName="Precipitation"
#rainLayer.LabelSet.LabelFont=Font("Arial",8);
#rainLayer.AddLabels();
rainLayer.IsMaskout = True
templayer.IsMaskout=True
#---- 添加图层
mapFrame.AddLayer(rainLayer)
mapFrame.AddLayer(templayer)
print "Display finished"
#---- 调整图层顺序(以避免压盖)
mapFrame.MoveLayerToBottom(rainLayer)
#---- 设置标题名称
title = "降水分布"
aText.SetLabelText(title)
#---- 设置图例名称
aLegend.Title = "降水量(毫米)"
#---- 绘制图形
mapLayout.PaintGraphics()
#---- 输出图形为文件
#mapLayout.ExportToPicture("E:\\Temp\\" + outFile)
#---- 显示程序窗体(只是为了看效果,自动运行时不需要)
#myApp.SaveFigure(time.strftime('%H')+".png")
mapLayout.ExportToPicture("d:\\kkk.PNG",800)
#Application.Run(myApp)
#myApp.Show() |
|