1、需要先定义一个转换方式 从一个地理坐标系转换到另一个地理坐标系
public static void alter() {
Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
ESRI.ArcGIS.DataManagementTools.CreateCustomGeoTransformation create = new ESRI.ArcGIS.DataManagementTools.CreateCustomGeoTransformation();
create.geot_name = "hhh";
ISpatialReferenceFactory spatialReferenceFact = new SpatialReferenceEnvironmentClass();
ISpatialReference pSR = spatialReferenceFact.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
create.in_coor_system = pSR;
create.out_coor_system = pSR;
create.custom_geot = "GEOGTRAN[METHOD['Geocentric_Translation'],PARAMETER['X_Axis_Translation',''],PARAMETER['Y_Axis_Translation',''],PARAMETER['Z_Axis_Translation','']]";
try
{
gp.Execute(create, null);
}
catch
{
for (int a = 0; a < gp.MessageCount; a++)
{
Console.WriteLine(gp.GetMessage(a) + "\n"); ;
}
}
}
2、使用上述地理坐标系 进行投影转换
到这一步时上一步自定义的方法不能用了,但是同一个地理坐标系内投影是可以转换的。(希望有大佬解答,怎么自定义转换方法,后续也可以使用的
#region 调用ArcToolBox投影工具
public static void alterSpatialReference(IGeoDataset pGeoData, ISpatialReference pSpatialReference, string transform_method, string outputPath)
{
Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
ESRI.ArcGIS.DataManagementTools.Project pro = new ESRI.ArcGIS.DataManagementTools.Project();
if (pGeoData != null)
{
IGeoDataset pGeoDataset = pGeoData;
pro.in_dataset = pGeoData;
pro.in_coor_system = pGeoDataset.SpatialReference;
pro.out_coor_system = pSpatialReference;
pro.out_dataset = outputPath;
pro.transform_method = transform_method;
try
{
gp.Execute(pro, null);
}
catch
{
for (int a = 0; a < gp.MessageCount; a++)
{
Console.WriteLine(gp.GetMessage(a) + "\n"); ;
}
}
}
}
#endregion