c#+ArcGIS Engine-獲取向量圖層的空間參考
阿新 • • 發佈:2019-02-07
介紹一種簡單的獲取向量圖層空間參考的方法:
首先開啟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;