前言:
求经纬度坐标系下的多边形的面积。
思路:
1、将Geometry的坐标系转换
2、求Geometry的面积
代码:
private double getArea(IGeometry pGeo) { IClone pClone = pGeo as IClone; IGeometry pArea = pClone.Clone() as IGeometry; ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment(); IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem(54013);//54013是世界投影 pArea.SpatialReference = m_SpatialReference; pArea.Project(pcs); return (pArea as IArea).Area; }
备注:
1、传入的Geometry必须本身要有ISpatialReference
2、IGeometry的Project方法是将Geometry由原来的投影转换成传入投影
3、54013是适用于全球,误差稍微大点
转载于:https://blog.51cto.com/zhangzt/1412329