ArcGIS Engine 10 开发手册(5-16)不同基准面的坐标转换

本文目录
  • 正文

通过前面的介绍,我们知道地球上同一位置的坐标在不同的基准面上是不一样的,而基准面是构成坐 标系的一个部分,因为基准面在定位的时候牵扯到了相对地心的平移或旋转等,所以对于这样的转换我们 无法直接进行,需要一个转换参数,而这些参数也是基于不同的模型的,常用的有三参数和 7 参数,三参 数是比较简单的也是比较容易理解的,三参数是在两个基准面之间进行了 X,Y,Z轴的平移,通过下面的图我们很清楚的看到三参数之间两个基准面的关系:

如果知道了这三个平移的参数 外加个基准面上的点,那么另外一个点的坐标就是

而7参数的模型比较复杂,这种复杂的同时让精度大为提高,7参数不仅仅考虑了两个基准面之间的平移,还考虑了旋转外加一个比例因子(椭球体的大小可能不一样),从下面的图我们可以清楚看到这种关系:

对于 7参数,我们知道了平移三参数旋转三参数以及比例因 子 外加一个基准面上的坐标就可按照下面的公式求出另外一个基准面上的坐标:

对于不同基准面之间的转换,ArcGIS Engine 提供了一个用来控制转换参数的接口 IGeoTransformation,该接口被以下类实现

着每一个接 口对应了一 种转换方法 ,比如 GeocentricTranslationClass 类就实 现了三参数 ,而 CoordinateFrameTransformationClass 类实现了7参数,要实现3参数或者7参数需要 IGeometry2 或更新接 口的 ProjectEx 方法,下面我们用代码实现一个不同基准面之间的坐标转换。

public void ProjectExExample ()

{

  ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass ();

  // ISpatialReference pFromCustom = pSpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile(@"E:\\arcgis\\Engine\\z idingyi.prj");

  IPoint pFromPoint = new PointClass ();
  pFromPoint.X = 518950.788;

  pFromPoint.Y = 4335923.97;

  IZAware pZAware = pFromPoint as IZAware;
  pZAware.ZAware = true;

  pFromPoint.Z = 958.4791;

  // ((IGeometry)pFromPoint).SpatialReference = pFromCustom;

  //自定义投影WGS84下的北京6度19带。 
  ((IGeometry)pFromPoint).SpatialReference = CreateCustomProjectedCoordinateSystem ();

  //目标投影

  IProjectedCoordinateSystem projectedCoordinateSystem =

    pSpatialReferenceFactory.CreateProjectedCoordinateSystem ((int) esriSRProjCS4Type.esr iSRProjCS_Xian1980_GK_Zone_19);

  //因为目标基准面和原始基准面不在同一个上,所以牵扯到参数转换,我用7参数转换

  ICoordinateFrameTransformation pCoordinateFrameTransformation = new CoordinateFrameTransformationClass ();

  pCoordinateFrameTransformation.PutParameters (-112.117, 4.530, 21.89,-0.00058702, -0.00476421, 0.00009358, 0.99998006411);

  pCoordinateFrameTransformation.PutSpatialReferences (CreateCustomProjectedCoordinate System (), projectedCoordinateSystem as ISpatialReference);

  //投影转换

  IGeometry2 pGeometry = pFromPoint as IGeometry2;

  pGeometry.ProjectEx (projectedCoordinateSystem as ISpatialReference, esriTransformDirection.esriTransformForward, pCoordinateFrameTransformation, false, 0, 0);

}

private IProjectedCoordinateSystem CreateCustomProjectedCoordinateSystem ()

{

  ISpatialReferenceFactory2 pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass ();

  IProjectionGEN pProjection = pSpatialReferenceFactory.CreateProjection ((int) esriSRProjectionType.esriSRProjection_GaussKruger) as IProjectionGEN;

  IGeographicCoordinateSystem pGeographicCoordinateSystem = pSpatialReferenceFactory.CreateGeographicCoordinateSystem ((int) esriSRGeoCSType.esri SRGeoCS_WGS1984);

  ILinearUnit pUnit = pSpatialReferenceFactory.CreateUnit ((int) esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;

  IParameter[] pParameters = pProjection.GetDefaultParameters ();

  IProjectedCoordinateSystemEdit pProjectedCoordinateSystemEdit = new ProjectedCoordinateSystemClass ();

  object pName = "WGS-BeiJing1954";
  object pAlias = "WGS-BeiJing1954";

  object pAbbreviation = "WGS-BeiJing1954";
  object pRemarks = "WGS-BeiJing1954";

  object pUsage = "Calculate Meter From lat and lon";

  object pGeographicCoordinateSystemObject = pGeographicCoordinateSystem as object;

  object pUnitObject = pUnit as object;

  object pProjectionObject = pProjection as object;
  object pParametersObject = pParameters as object;

  pProjectedCoordinateSystemEdit.Define (ref pName, ref pAlias, ref pAbbreviation, ref pRemarks, ref pUsage, ref pGeographicCoordinateSystemObject, ref pUnitObject, ref pProjectionObject, ref pParametersObject);

  IProjectedCoordinateSystem5 pProjectedCoordinateSystem = pProjectedCoordinateSystemEdit as IProjectedCoordinateSystem5;

  pProjectedCoordinateSystem.FalseEasting = 500000;

  pProjectedCoordinateSystem.LatitudeOfOrigin = 0;
  pProjectedCoordinateSystem.set_CentralMeridian (true, 111);

  pProjectedCoordinateSystem.ScaleFactor = 1;
  pProjectedCoordinateSystem.FalseNorthing = 0;

  return pProjectedCoordinateSystem;

}

ArcGIS Engine 10 开发手册全集

ArcGIS Engine 10 开发手册全集: ArcGIS Engine 10 开发手册

如果本文对你有所帮助,欢迎对我们团队进行打赏捐助,让我们在传播3S的路上可以走得更远。
赞赏支持
微信捐助麻辣GIS 支付宝捐助麻辣GIS

麻辣GIS-Sailor
作者:
GIS爱好者,学GIS,更爱玩GIS。

如您有疑问,可在文末留言,也可在 麻辣GIS•小分队 搜索回答或发帖 ,还可以在QQ群中提问。

本站QQ群(一):291616564 麻辣GIS

本站QQ群(二):166408035 麻辣GIS(二)

本站QQ群(三):627853279 麻辣GIS(三)

微信公众号:malagis,扫描右边二维码直接关注。

发表评论