ArcEngine下投影坐标和经纬度坐标的相互转换

来源:互联网 发布:程序员电脑壁纸高清 编辑:程序博客网 时间:2024/04/29 20:24

投影转经纬度

private IPoint PRJtoGCS(double x, double y)
{
    IPoint pPoint =
new PointClass();
    pPoint.PutCoords(x, y);
    ISpatialReferenceFactory pSRF =
new SpatialReferenceEnvironmentClass();
    pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(
2414);
pPoint.Project(pSRF.CreateGeographicCoordinateSystem((
int)esriSRGeoCSType.esriSRGeoCS_Beijing1954));
   
return pPoint;
}

 

其中,pPoint.SpatialReference =pSRF.CreateProjectedCoordinateSystem(2414);

这行代码是设置pPoint的空间参考,也就是要转化的点的投影坐标。如果不知道投影坐标的话,转化会报异常。

2414为该投影的enum

pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954));
将该点的投影坐标转化为经纬度。

 

经纬度到投影:

private IPoint GCStoPRJ(IPoint pPoint,int GCSType,int PRJType)
{
    ISpatialReferenceFactory pSRF =
new SpatialReferenceEnvironmentClass();
    pPoint.SpatialReference =pSRF.CreateGeographicCoordinateSystem(GCSType);
   pPoint.Project(pSRF.CreateProjectedCoordinateSystem(PRJType));
   
return pPoint;
}

 

原创粉丝点击