得到shp文件的坐标系
filePath为路径,比如:D\Documents and Settings\Administrator\桌面\shp\b.shp
private string getSpatialReference(string filePath)
{
string strSpatialReference = "";
if (filePath.Length > 0)
{
string WorkSpacePath = System.IO.Path.GetDirectoryName(filePath);
//获得打开IFeatureClass的字符串数组
string ShapeFileName = System.IO.Path.GetFileName(filePath);
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(WorkSpacePath, 0);
IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(ShapeFileName);
IDataset pDataset = pFeatureClass as IDataset;
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.FeatureClass = pFeatureClass;
pFeatureLayer.Name = pDataset.Name;
strSpatialReference = pFeatureLayer.AreaOfInterest.SpatialReference.Name;
}
return strSpatialReference;
}