码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGIS Engine中空间参照(地理坐标)相关方法总结

时间:2017-01-19 09:37:14      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:sys   cst   public   ret   alter   arc   空间参照   要素类   sum   

转自原文ArcGIS Engine中空间参照(地理坐标)相关方法总结

 

1.创建空间参考

  1. /// <summary>  
  2. /// 根据prj文件创建空间参考  
  3. /// </summary>  
  4. /// <param name="strProFile">空间参照文件</param>  
  5. /// <returns></returns>  
  6. public static ISpatialReference CreateSpatialReference(string strProFile)  
  7. {  
  8.     ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass();  
  9.     ISpatialReference pSpatialReference = pSpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile(strProFile);  
  10.     return pSpatialReference;             
  11. }  
  1. /// <summary>  
  2. /// 创建地理坐标系  
  3. /// </summary>  
  4. /// <param name="gcType">esriSRProjCS4Type</param>  
  5. /// <returns></returns>  
  6. public static ISpatialReference CreateGeographicCoordinate(esriSRProjCS4Type gcsType)  
  7. {  
  8.     ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass();  
  9.     ISpatialReference pSpatialReference = pSpatialReferenceFactory.CreateGeographicCoordinateSystem((int)gcsType);  
  10.     return pSpatialReference;  
  11. }  
  1. /// <summary>  
  2. /// 创建投影坐标系  
  3. /// </summary>  
  4. /// <param name="pcType">esriSRProjCS4Type</param>  
  5. /// <returns></returns>  
  6. public static ISpatialReference CreateProjectedCoordinate(esriSRProjCS4Type pcsType)  
  7. {  
  8.     ISpatialReferenceFactory2 pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass();  
  9.     ISpatialReference pSpatialReference = pSpatialReferenceFactory.CreateProjectedCoordinateSystem((int)pcsType);  
  10.     return pSpatialReference;  
  11. }  
  1. /// <summary>  
  2. /// 获取空投影  
  3. /// </summary>  
  4. /// <returns></returns>  
  5. public static ISpatialReference CreateUnKnownSpatialReference()  
  6. {  
  7.     ISpatialReference pSpatialReference = new UnknownCoordinateSystemClass();  
  8.     pSpatialReference.SetDomain(0, 99999999, 0, 99999999);//设置空间范围  
  9.     return pSpatialReference;  
  10. }  

2.获取空间参考

  1. /// <summary>  
  2. /// 获取要素集空间参考  
  3. /// </summary>  
  4. /// <param name="pFeatureDataset">要素集</param>  
  5. /// <returns></returns>  
  6. public static ISpatialReference GetSpatialReference(IFeatureDataset pFeatureDataset)  
  7. {  
  8.     IGeoDataset pGeoDataset = pFeatureDataset as IGeoDataset;  
  9.     ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;  
  10.     return pSpatialReference;             
  11. }  
  1. /// <summary>  
  2. /// 获取要素层空间参考  
  3. /// </summary>  
  4. /// <param name="pFeatureLayer">要素层</param>  
  5. /// <returns></returns>  
  6. public static ISpatialReference GetSpatialReferenc(IFeatureLayer pFeatureLayer)  
  7. {IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;  
  8.     IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;  
  9.     ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;  
  10.     return pSpatialReference;             
  11. }  
  1. /// <summary>  
  2. /// 获取要素类空间参考  
  3. /// </summary>  
  4. /// <param name="pFeatureClass">要素类</param>  
  5. /// <returns></returns>  
  6. public static ISpatialReference GetSpatialReference(IFeatureClass pFeatureClass)  
  7. {  
  8.     IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;  
  9.     ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;  
  10.     return pSpatialReference;             
  11. }  

3.修改空间参考

  1. /// <summary>  
  2. /// 修改要素集空间参考  
  3. /// </summary>  
  4. /// <param name="pFeatureDataset">要素集</param>  
  5. /// <param name="pSpatialReference">新空间参考</param>  
  6. public static void AlterSpatialReference(IFeatureDataset pFeatureDataset, ISpatialReference pSpatialReference)  
  7. {  
  8.     IGeoDataset pGeoDataset = pFeatureDataset as IGeoDataset;  
  9.     IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit;  
  10.     if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true)  
  11.         pGeoDatasetSchemaEdit.AlterSpatialReference(pSpatialReference);  
  12. }  
  1. /// <summary>  
  2. /// 修改要素类空间参考  
  3. /// </summary>  
  4. /// <param name="pFeatureClass">要素类</param>  
  5. /// <param name="pSpatialReference">新空间参考</param>  
  6. public static void AlterSpatialReference(IFeatureClass pFeatureClass, ISpatialReference pSpatialReference)  
  7. {  
  8.     IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;  
  9.     IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit;  
  10.     if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true)  
  11.         pGeoDatasetSchemaEdit.AlterSpatialReference(pSpatialReference);  
 

ArcGIS Engine中空间参照(地理坐标)相关方法总结

标签:sys   cst   public   ret   alter   arc   空间参照   要素类   sum   

原文地址:http://www.cnblogs.com/arxive/p/6305413.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!