来自: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; 
}

相关文章:

  • 2021-12-04
  • 2021-12-27
  • 2021-12-29
  • 2021-05-01
  • 2021-11-28
  • 2022-12-23
  • 2021-12-15
猜你喜欢
  • 2021-05-20
  • 2021-07-13
  • 2022-12-23
  • 2021-12-10
  • 2021-05-28
相关资源
相似解决方案