ArcEngine下投影坐标和经纬度坐标的相互转换
投影转经纬度
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;
}
转载自:https://blog.csdn.net/jianzhanger/article/details/6322177