• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

Engine中如何进行七参数投影转换?

来自:http://zhihu.esrichina.com.cn/?/question/6858

解决办法】:
首先创建自定义geotransformation,然后用IGeometry.ProjectEx进行投影转换。参考代码(以wgs1984转到Xian80为例):

private void func1ToolStripMenuItem_Click(object sender, EventArgs e) 
{ 
Type t = Type.GetTypeFromProgID(esriGeometry.SpatialReferenceEnvironment); 
System.Object obj = Activator.CreateInstance(t); 
ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory; 
IGeographicCoordinateSystem wgs84GCS = srFact.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); 
IProjectedCoordinateSystem xian80PCS = srFact.CreateProjectedCoordinateSystem((int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_CM_102E); 

IGeoTransformation geoTrans = CreateGeoTransformation((ISpatialReference)wgs84GCS, (ISpatialReference)xian80PCS); 

IWorkspaceFactory wksfac = new FileGDBWorkspaceFactoryClass(); 
IFeatureWorkspace feawks = wksfac.OpenFromFile(@E:TEST.gdb,0) as IFeatureWorkspace; 
IFeatureClass fc = feawks.OpenFeatureClass(POINT); 
IFeature fea = fc.Search(null, false).NextFeature(); 
IGeometry5 geometry; 
IPoint point = fea.ShapeCopy as IPoint; 
geometry = point as IGeometry5; 
geometry.SpatialReference = wgs84GCS; 

geometry.ProjectEx(xian80PCS, esriTransformDirection.esriTransformForward, geoTrans, false, 0.0, 0.0); 
point = geometry as IPoint; 
MessageBox.Show(point.X.ToString(),point.Y.ToString()); 
} 

private IGeoTransformation CreateGeoTransformation(ISpatialReference pInputSR, ISpatialReference pOutputSR) 
{ 
IGeoTransformation pGeoTrans; 
pGeoTrans = new CoordinateFrameTransformationClass(); 

((ICoordinateFrameTransformation)pGeoTrans).PutSpatialReferences(pInputSR, pOutputSR); 
((ICoordinateFrameTransformation)pGeoTrans).PutParameters(p1, p2, p3, p4, p5, p6, p7); 

return pGeoTrans; 
}

posted on 2016-02-23 15:23  gisai  阅读(908)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3