登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2013-11-14 11:48 编辑
用脚本程序来创建一个Polygon图层:
- #-------------------------------------------------------- # Author: Yaqiang Wang
- # Date: 2013-11-14
- # Purpose: Create a polygon layer
- # Note: Sample
- #-----------------------------------------------------------
- #---- Import clr and classes
- import clr
- clr.AddReference("MeteoInfoC.dll")
- from System import *
- from System.Collections.Generic import *
- from MeteoInfoC import *
- from MeteoInfoC.Layer import *
- from MeteoInfoC.Shape import *
- from MeteoInfoC.Legend import *
- #---- Create a polygon layer
- print 'Create a polygon layer...'
- pLayer = VectorLayer(ShapeTypes.Polygon)
- pLayer.LayerName = "Test_Polygon"
- pLayer.Visible = True
- pLayer.EditAddField("ID", Int32)
- #---- Create a polygon shape
- plist = List[PointD]()
- plist.Add(PointD(80, 35))
- plist.Add(PointD(83, 38))
- plist.Add(PointD(86, 40))
- plist.Add(PointD(88, 38))
- plist.Add(PointD(86, 36))
- plist.Add(PointD(82, 34))
- plist.Add(PointD(80, 35))
- pShape = PolygonShape()
- pShape.Points = plist
- #--- Add polygon shape into the polygon layer
- shapeNum = pLayer.ShapeNum
- i = 1
- if pLayer.EditInsertShape(pShape, shapeNum):
- pLayer.EditCellValue("ID", shapeNum, i)
- i += 1
- pLayer.UpdateLegendScheme(LegendType.SingleSymbol, "ID")
- #---- Add the polygon layer
- mipy.MapDocument.ActiveMapFrame.AddLayer(pLayer)
- print 'Finished!'
运行结果:
|