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

原创 2014年08月23日 09:38:50

1.创建空间参考

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

2.获取空间参考

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

3.修改空间参考

        /// <summary>
        /// 修改要素集空间参考
        /// </summary>
        /// <param name="pFeatureDataset">要素集</param>
        /// <param name="pSpatialReference">新空间参考</param>
        public static void AlterSpatialReference(IFeatureDataset pFeatureDataset, ISpatialReference pSpatialReference)
        {
            IGeoDataset pGeoDataset = pFeatureDataset as IGeoDataset;
            IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit;
            if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true)
                pGeoDatasetSchemaEdit.AlterSpatialReference(pSpatialReference);
        }
        /// <summary>
        /// 修改要素类空间参考
        /// </summary>
        /// <param name="pFeatureClass">要素类</param>
        /// <param name="pSpatialReference">新空间参考</param>
        public static void AlterSpatialReference(IFeatureClass pFeatureClass, ISpatialReference pSpatialReference)
        {
            IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;
            IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit;
            if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true)
                pGeoDatasetSchemaEdit.AlterSpatialReference(pSpatialReference);
        }

版权声明:本站所有文章均为博主整理或原创,转载时请务必注明出处!QQ492384481

相关文章推荐

IFeature IFeatureClass IFeatureDataset等接口的介绍

IFeature IFeatureClass IFeatureDataset等接口的介绍 摘自帮助文档   IFeature Interface Feature指的是空间对象,它包含在一个...
  • CA431
  • CA431
  • 2015年08月12日 20:20
  • 1384

遍历IFeatureDataset中的FeatureClass

IFeatureWorkspace m_FeatureWorkspace; m_FeatureWorkspace=(IFeatureWorkspace)m_SdeWorkSpace;        ...
  • muzai
  • muzai
  • 2010年08月12日 14:50
  • 5239

IWorkspace操作

1、创建工作空间 public static IWorkspace CreateWorkspace(string pName, string pPath) { ...

建立空间参考 ISpatialReference

ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();         ...

ArcGIS Engine代码共享-投影(SpatialReference)对象操作

public class SpatialReferenceHelper { // Fields private const double ParaC = 639...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

ArcEngine设置坐标系

ArcGIS Engine提供了一系列对象供开发者管理GIS系统的坐标系统。 对大部分开发者而言了解ProjectedCoordinateSystem, GeographicCoordinateSy...

ArcEngine下投影坐标和经纬度坐标的相互转换

坐标转换

ArcEngine实现坐标转换和投影

3.1 矢量数据投影和坐标转换 相关接口 3.1.1 IGeometry.Project方法 该方法声明如下: (C#语法) public void Project (   ISpat...
  • sunj92
  • sunj92
  • 2016年04月29日 14:52
  • 2161

ArcGlobe三维开发之十五——使用对话框设置坐标参考系(ISpatialReferenceDialog2)

最近在学习新的东西的时候也对之前写的程序做了优化。今天在使用对话框设置坐标参考的时候遇到了一点问题,特此备注,希望能帮到遇到同样问题的童鞋。 我是写的用Excel生成shape文件,之前写的是先生成s...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:ArcGIS Engine中空间参照(地理坐标)相关方法总结
举报原因:
原因补充:

(最多只允许输入30个字)