转自原文c#+ArcGIS Engine-获取矢量图层的空间参考

介绍一种简单的获取矢量图层空间参考的方法:
首先打开Shp文件获得FeatureClass,代码如下:

string pPath="D:\\test.shp";
string pFolder=Path.GetDirectoryName (pPath);
string pFileName=Path.GetFileName(pPath);
IWorkspace pWorkspace=pWorkspaceFactory .OpenFromFile(pFolder ,0);
IFeatureWorkspace pFeatureWorkspace =pWorkspace as IFeatureWorkspace ;
IFeatureClass pFeatureClass=pFeatureWorkspace .OpenFeatureClass (pFileName );
然后 由FeatureClass得到空间参考,代码如下:
IGeoDataset pGeoDataset = (IGeoDataset)pFeatureClass;
ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;
05-17 05:51