- 积分
- 57081
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
发表于 2012-9-26 23:17:13
|
显示全部楼层
vortexroc 发表于 2012-9-26 22:37
就是先添加面图层,然后用MeteoInfo软件工具栏的“添加点”功能在某些位置添加了一些点,现在想保存这些点 ...
加载中国省级Polygon图层,用New Point工具手动加一些点,写脚本程序输出这些点的坐标及所在的省份。
完整的代码如下:
- #--------------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2012-9-26
- # Purpose: Output the Lon/Lat and position of the points
- # Note: Sample
- #-----------------------------------------------------------
- #---- Import clr and classes
- import clr
- clr.AddReference("MeteoInfoC.dll")
- from MeteoInfoC import *
- from MeteoInfoC.Geoprocess import *
- #---- Get polygon layer
- aLayer = mipy.MapDocument.ActiveMapFrame.MapView.GetLayerFromName("bou2_4p.shp")
- print aLayer.LayerName
- #---- Determin the points position
- for gPoint in mipy.MapDocument.ActiveMapFrame.MapView.GraphicCollection.GraphicList:
- aP = gPoint.Shape.Point
- province = "不在图层范围内"
- i = 0
- for polygon in aLayer.ShapeList:
- if GeoComputation.PointInPolygon(polygon, aP):
- province = aLayer.GetCellValue("Name", i)
- break
- i += 1
-
- print "经度: %6.2f, 纬度: %6.2f, 省份: %s" % (aP.X, aP.Y, province)
复制代码
|
|