ArcEngine下投影座標和經緯度座標的相互轉換

jianzhanger發表於2011-04-14

投影轉經緯度

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;
}

 

相關文章