pFeatureLayer为图层,gcsType代表坐标系代号(例如:4214代表Beijing1954 )
try
{
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;
IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit;
if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true)
{
ISpatialReferenceFactory2 pSpaRefFactory = new SpatialReferenceEnvironmentClass();
IGeographicCoordinateSystem pNewGeoSys = pSpaRefFactory.CreateGeographicCoordinateSystem(gcsType);
pGeoDatasetSchemaEdit.AlterSpatialReference(pNewGeoSys);
}
}
catch (Exception Err)
{
MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}