利用ArcObject实现 ArcMap Toolbox的 Define Projection工具
实现代码如下:
/// <summary>
/// 用于未知空间参考坐标系的数据集赋予空间参考坐标系,且会覆盖已存在的空间参考系
/// </summary>
/// <param name="geoDataset"></param>
/// <param name="spatialReference"></param>
/// <param name="isSucceed"></param>
public void DefineProjection(
IGeoDataset geoDataset,
ISpatialReference spatialReference,
out bool isSucceed)
{
isSucceed = false;
IGeoDatasetSchemaEdit geoDatasetSchemaEidt = geoDataset as IGeoDatasetSchemaEdit;
if (geoDatasetSchemaEidt.CanAlterSpatialReference == true)
{
geoDatasetSchemaEidt.AlterSpatialReference(spatialReference);
isSucceed = true;
}
}