基于C#的ArcEngine二次开发41:投影坐标系与地理坐标系接口、方法及示例代码

空间参考是地理空间要素的重要属性,也是地理信息数据处理的关键要素;本文将对Arcengine中与地图投影相关的接口及方法进行系统而全面的分析,希望能为大家的工作和学习提供一定的帮助。

主要介绍IGeographicCoordinateSystem,IProjectedCoordinateSystem和ISpatialReferenceFactory三个接口的成员及示例代码

几点总结:

类别坐标系统名称工厂代码说明
投影坐标系CGCS2000_3_Degree_GK_CM_75E 45342000坐标系下3度分带75度分带坐标,横坐标前不加带号
CGCS2000_3_Degree_GK_Zone_2545132000坐标系下3度分带25带,横坐标前加带号
CGCS2000_GK_Zone_1344912000坐标系下6度分带13带,横坐标前加带号
CGCS2000_GK_CM_75E 45022000坐标系下6度分带75度分带坐标,横坐标前不加带号
地理坐标系GCS_China_Geodetic_Coordinate_System_2000 44902000地理坐标

 

1 地理坐标系与投影坐标系

地理坐标系是以经纬度表示地面目标信息的坐标系统,投影坐标系是有XY表示地面坐标信息的坐标系统

1.1 IGeographicCoordinateSystem

地理坐标,使用经纬度地理信息

该接口在10.1版本中已被IGeographicCoordinateSystem2接口替换,它提供了所有与地理坐标系统相关的属性。

属性/方法英文描述中文注释
AbbreviationThe abbreviated name of this spatial reference component.此空间引用组件的名称缩写
AliasThe alias of this spatial reference component.此空间引用组件的别名
ChangedNotify this object that some of its parts have changed (parameter values, z unit, etc.). 
CoordinateUnitThe angular unit of this geographic coordinate system.地理坐标系统的角度单位
DatumThe horizontal datum of this geographic coordinate system.地理坐标系统的水平基准
FactoryCodeThe factory code (WKID) of the spatial reference.

投影引擎对象类型的唯一整数标识符,自定义投影坐标系该参数默认为0;具体整数值参见ISpatialReferenceFactory::CreateProjectedCoordinateSystem

方法

GetDomainThe XY domain extent.得到XY的区域范围
GetFalseOriginAndUnitsGet the false origin and units.得到XY域的最小坐标和分辨率的倒数
GetMDomainThe measure domain extent.得到XY域的最小坐标
GetMFalseOriginAndUnitsGet the measure false origin and units. 
GetZDomainThe Z domain extent. 
GetZFalseOriginAndUnitsGet the Z false origin and units.得到Z坐标方向上的最小值和单位
HasMPrecisionReturns true when m-value precision information has been defined.定义M值精度时,使用该参数
HasXYPrecisionReturns true when (x,y) precision information has been defined.定义(x,y)值精度时,使用该参数
HasZPrecisionReturns true when z-value precision information has been defined. 
IsPrecisionEqualReturns TRUE when the precision information for the two spatial references is the same. 
NameThe name of this spatial reference component. 
PrimeMeridianThe prime meridian of this geographic coordinate system. 
RemarksThe comment string of this spatial reference component. 
SetDomainThe XY domain extent. 
SetFalseOriginAndUnitsSet the false origin and units. 
SetMDomainThe measure domain extent. 
SetMFalseOriginAndUnitsSet the measure false origin and units. 
SetZDomainThe Z domain extent. 
SetZFalseOriginAndUnitsSet the Z false origin and units. 
UsageThe usage notes of this geographic coordinate system. 
ZCoordinateUnitThe unit for the Z coordinate. 

1.2 IProjectedCoordinateSystem

投影坐标系,目前已经升级到IProjectedCoordinateSystem5

MemberDescription
AbbreviationThe abbreviated name of this spatial reference component.
AliasThe alias of this spatial reference component.
AzimuthThe azimuth of a projected coordinate system.
CentralMeridianThe central meridian (Lambda0) of a projected coordinate system.
CentralParallelThe central parallel (Phi 0) of a projected coordinate system.
ChangedNotify this object that some of its parts have changed (parameter values, z unit, etc.).
ConvergenceAngleReturns the grid convergence angle .
CoordinateUnitThe linear unit of a projected coordinate system.
FactoryCodeThe factory code (WKID) of the spatial reference.
FalseEastingThe false easting (X0) of a projected coordinate system.
FalseNorthingThe false northing (Y0) of a projected coordinate system.
ForwardProjects points from geographic to planar coordinates.
GeographicCoordinateSystemThe geographic coordinate system of a projected coordinate system.
GetCentralLongitudeReturns CentralLongitude of the projected coordinate system. Always defined, unlike CentralMeridian or LongitudeOfCenter.
GetDomainThe XY domain extent.
GetFalseOriginAndUnitsGet the false origin and units.
GetGCSParamsReturns 180 degrees and horizon delta in proper GCS units.
GetHorizonReturns the standard horizon polygon, its envelope, and whether it is inclusive or exclusive; the horizon polygon may be 0.
GetMDomainThe measure domain extent.
GetMFalseOriginAndUnitsGet the measure false origin and units.
GetNorthPoleReturns the north pole in projected coordinates, or an empty point if the north pole is outside the PCS horizon.
GetNorthPoleGeometryReturns type of north pole geometry.
GetNorthPoleLocationReturns type of location of north pole with respect to the PCS horizon.
GetParametersGets the map projection parameters of a projected coordinate system.
GetPCSHorizonReturns PCS horizon polygon, its envelope and whether it is inclusive or exclusive; the horizon polygon may be 0.
GetShiftedHorizonReturns the horizon polygon, shifted once or twice, west/east of the standard horizon for a negative/positive shift.
GetSouthPoleReturns the south pole in projected coordinates, or an empty point if the south pole is outside the PCS horizon.
GetSouthPoleGeometryReturns type of south pole geometry.
GetSouthPoleLocationReturns type of location of south pole with respect to the PCS horizon.
GetZDomainThe Z domain extent.
GetZFalseOriginAndUnitsGet the Z false origin and units.
HasMPrecisionReturns true when m-value precision information has been defined.
HasXYPrecisionReturns true when (x,y) precision information has been defined.
HasZPrecisionReturns true when z-value precision information has been defined.
HeightThe height above the sphere in projected coordinate system units.
HorizonThe mathematical limits of a projected coordinate system.
HorizonCountThe number of shapes that describe the limits of a ProjCS.
InverseProjects points from planar to geographic coordinates.
InverseWithShiftProjects points from planar to geographic coordinates. Deals with geographic coordinates in ranges other than +-180.
IsCentralLongitudeVerticalReturns true if central meridian is a straight vertical line.
IsEqualNoNamesCompares to projected coordinate systems for equality but ignores their names.
IsHorizonConvexHullReturns true if PCS horizon is convex.
IsHorizonEdgeDuplicatedReturns true if some edges of PCS horizon project inversely to identical lines.
IsHorizonEntireWorldReturns true if PCS horizon contains the entire world.
IsPrecisionEqualReturns TRUE when the precision information for the two spatial references is the same.
LatitudeOf1stThe latitude of the first point (Phi 1) of a projected coordinate system.
LatitudeOf2ndThe latitude of the second point (Phi 2) of a projected coordinate system.
LatitudeOfCenterThe latitude of center (Phi C) of a projected coordinate system.
LatitudeOfOriginThe latitude of the origin (Phi 0) of a projected coordinate system.
LongitudeOf1stThe longitude of the first point (Lambda 1) of a projected coordinate system.
LongitudeOf2ndThe longitude of the second point (Lambda 2) of a projected coordinate system.
LongitudeOfCenterThe longitude of center (Lam C) of a projected coordinate system.
LongitudeOfOriginThe longitude of origin (Lambda0) of a projected coordinate system.
NameThe name of this spatial reference component.
ProjectionThe map projection of a projected coordinate system.
PseudoStandardParallel1The latitude on an oblique spheroid that defines the oblique cone for a Krovak projected coordinate system.
PutLinearAndAngularUnitsModify linear unit of projected coordinates and angular unit of associated geographic coordinates.
RemarksThe comment string of this spatial reference component.
RotationThe rotation value used to change the axis directions in a Krovak projected coordinate system.
ScaleFactorThe scale factor (K0) of a projected coordinate system.
SetDomainThe XY domain extent.
SetFalseOriginAndUnitsSet the false origin and units.
SetMDomainThe measure domain extent.
SetMFalseOriginAndUnitsSet the measure false origin and units.
SetZDomainThe Z domain extent.
SetZFalseOriginAndUnitsSet the Z false origin and units.
StandardParallel1The first parallel (Phi 1) of a projected coordinate system.
StandardParallel2The second parallel (Phi 2) of a projected coordinate system.
UsageThe usage notes of a projected coordinate system.
XScaleFactorThe X axis scale value used to flip the axis direction in a Krovak projected coordinate system.
YScaleFactorThe Y axis scale value used to flip the axis direction in a Krovak projected coordinate system.
ZCoordinateUnitThe unit for the Z coordinate.

 

 

2. ISpatialReferenceFactory

此接口已被ISpatialReferenceFactory3所代替,

2.1 接口方法概览

AllPropertiesMethodsDescription备注
CreateDatumCreates a predefined datum.创建一个预定义椭球
CreateESRISpatialReferenceCreates a spatial reference system and defines it from the specified ESRISpatialReference buffer.创建一个由ESRISpatialReference定义的空间参考系统
CreateESRISpatialReferenceFromPRJCreates a spatial reference from a PRJ string.根据一个投影字符串创建一个空间参考
CreateESRISpatialReferenceFromPRJFileCreates a spatial reference from a PRJ file.根据投影文件创建空间参考
CreateGeographicCoordinateSystemCreates a predefined geographic coordinate system.创建预定义的地理坐标系统
CreateGeoTransformationCreates a predefined transformation between geographic coordinate systems.在两个地理坐标系之间创建一个预定变换
CreateParameterCreates a predefined parameter.创建一个预定义参数 
CreatePredefinedAngularUnitsCreates a list of predefined angular units.创建预定义角度单位列表
CreatePredefinedDatumsCreates a list of a list of predefined datums.创建预定义基准列表
CreatePredefinedLinearUnitsCreates a list of predefined linear units.创建预定义的长度单位列表
CreatePredefinedPrimeMeridiansCreates a list of predefined prime meridians.创建预定义基本子午线列表
CreatePredefinedProjectionsCreates a list of predefined projections.创建预定义的投影列表
CreatePredefinedSpheroidsCreates a list of predefined spheroids.创建预定义椭球列表
CreatePrimeMeridianCreates a predefined prime meridian.创建基本子午线
CreateProjectedCoordinateSystemCreates a predefined projected coordinate system.创建投影坐标系统
CreateProjectionCreates a predefined projection.创建预定义投影
CreateSpheroidCreates a predefined spheroid.创建预定义椭球
CreateUnitCreates a predefined unit of measure.创建预定义测度dan
ExportESRISpatialReferenceToPRJFileExports a spatial reference to a PRJ file.输出ESRI空间参考到投影文件

2.2 ISpatialReferenceFactory.CreateGeographicCoordinateSystem

public IGeographicCoordinateSystem CreateGeographicCoordinateSystem (int gcsType);

其参数由 esriSRGeoCSTypeesriSRGeoCS2Type, or esriSRGeoCS3Type枚举器提供

使用代码示例

 ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
//Create a geographic coordinate system using the available geographic
//coordinate systems. These can be found in the esriGeometry esriSRGeoCSType
//enumeration.
IGeographicCoordinateSystem geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

2.2.1 Creating a predefined geographic coordinate system

ISpatialReferenceFactory 可以创建一个被 esriSRGeoCSType, esriSRGeoCS2Type, and esriSRGeoCS3Type枚举列表中包含的地理坐标系统

private void CreateGeographicCoordinateSystem()
{
    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.

    Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
    System.Object obj = Activator.CreateInstance(t);
    ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory;

    // Use the enumeration to create an instance of the predefined object.

    IGeographicCoordinateSystem geographicCS =
        srFact.CreateGeographicCoordinateSystem((int)
        esriSRGeoCSType.esriSRGeoCS_NAD1983);
}

2.2.2 Creating a custom geographic coordinate system

一个基本的地理坐标系统包括名称、角度单位、基准基本子午线,他是一个描述三维地球模型的坐标系统;我们可以通过IGeographicCoordinateSystem 接口获取主要的属性和方法,以及IGeographicCoordinateSystem2定义的额外属性;虽然我们不需要创建地理坐标系,但是IGeographicCoordinateSystemEdit 接口包含Define 和DefineEx 方法。

A GCS includes a name, angular unit of measure, datum (which includes a spheroid), and a prime meridian. It is a model of the earth in a three-dimensional (3D) coordinate system. Latitude-longitude or lat/lon data is in a GCS. You can access the majority of the properties and methods through the IGeographicCoordinateSystem interface with additional properties that are available in IGeographicCoordinateSystem2. Although most developers will not need to create a custom GCS, IGeographicCoordinateSystemEdit contains the Define and DefineEx methods.

下面是如何使用Define 方法创建用户定义GCS的示例,ISpatialReferenceFactory 允许创建基准、本初子午线、角度三维等要素

The following code example shows how to use the Define method to create a user-defined GCS. The ISpatialReferenceFactory interface allows you to create the Datum, PrimeMeridian, and AngularUnit component parts. These components can also be created using a similar Define method available on their classes.

private IGeographicCoordinateSystem CreateGeographicCoordinateSystem()
{
    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type factoryType = Type.GetTypeFromProgID(
        "esriGeometry.SpatialReferenceEnvironment");
    System.Object obj = Activator.CreateInstance(factoryType);
    ISpatialReferenceFactory3 spatialReferenceFactory = obj as
        ISpatialReferenceFactory3;

    // Create the datum, prime meridian, and angular unit from existing definitions.
    IDatum datum = spatialReferenceFactory.CreateDatum((int)
        esriSRDatumType.esriSRDatum_OSGB1936);
    IPrimeMeridian primeMeridian = spatialReferenceFactory.CreatePrimeMeridian((int)
        esriSRPrimeMType.esriSRPrimeM_Greenwich);
    IUnit unit = spatialReferenceFactory.CreateUnit((int)
        esriSRUnitType.esriSRUnit_Degree);

    IGeographicCoordinateSystemEdit geographicCoordinateSystemEdit = new
        GeographicCoordinateSystemClass();

    object name = "UserDefined Geographic Coordinate System";
    object alias = "UserDefined GCS";
    object abbreviation = "UserDefined";
    object remarks = "User Defined Geographic Coordinate System based on OSGB1936";
    object usage = "Suitable for the UK";
    object datumObject = datum as object;
    object primeMeridianObject = primeMeridian as object;
    object unitObject = unit as object;

    geographicCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref
        remarks, ref usage, ref datumObject, ref primeMeridianObject, ref unitObject)
        ;

    IGeographicCoordinateSystem userDefinedGeographicCoordinateSystem =
        geographicCoordinateSystemEdit as IGeographicCoordinateSystem;
    return userDefinedGeographicCoordinateSystem;

}

下面是使用DefineEx 创建定义投影的例子,它使用 SpatialReferenceEnvironment  接口创建基准、本初子午线和单位

The following code example shows how the DefineEx method can be used. It uses SpatialReferenceEnvironment to create the Datum, PrimeMeridian, and Unit components:

private IGeographicCoordinateSystem CreateGeographicCoordinateSystemEx()
{

    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
    System.Object obj = Activator.CreateInstance(t);
    ISpatialReferenceFactory3 spatialReferenceFactory = obj as
        ISpatialReferenceFactory3;

    // Create the datum, prime meridian, and angular unit from existing definitions.

    IDatum datum = spatialReferenceFactory.CreateDatum((int)
        esriSRDatumType.esriSRDatum_OSGB1936);
    IPrimeMeridian primeMeridian = spatialReferenceFactory.CreatePrimeMeridian((int)
        esriSRPrimeMType.esriSRPrimeM_Greenwich);
    IUnit unit = spatialReferenceFactory.CreateUnit((int)
        esriSRUnitType.esriSRUnit_Degree);

    IGeographicCoordinateSystemEdit geographicCoordinateSystemEdit = new
        GeographicCoordinateSystemClass();

    String name = "UserDefined Geographic Coordinate System";
    String alias = "UserDefined GCS";
    String abbreviation = "UserDefined";
    String remarks = "User Defined Geographic Coordinate System based on OSGB1936";
    String usage = "Suitable for the UK";

    geographicCoordinateSystemEdit.DefineEx(name, alias, abbreviation, remarks,
        usage, datum, primeMeridian, unit as IAngularUnit);

    IGeographicCoordinateSystem userDefinedGeographicCoordinateSystem =
        geographicCoordinateSystemEdit as IGeographicCoordinateSystem;

    return userDefinedGeographicCoordinateSystem;

}

2.2.3 esriSRGeoCS3Type 

几个常见的椭球编码:WGS-84(4326), Xian-80(4610), GCS-2000(4490)

更为详细的编码,参见文章:https://www.cnblogs.com/liweis/p/5951032.html

2.3 其他方法

2.3.1 ISpatialReferenceFactory.CreateDatum

public IDatum CreateDatum (int datumType);

参数由 esriSRDatumTypeesriSRDatum2Type, or esriSRDatum3Type 枚举器提供

ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); 
//Create the datum using the available datums. These can be 
//found in the esriGeometry esriSRDatumType enumeration. 
IDatum datum = spatialReferenceFactory.CreateDatum((int)esriSRDatumType.esriSRDatum_NAD1983);

2.3.2 ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile

public ISpatialReference CreateESRISpatialReferenceFromPRJFile (stringprjFile);
    public void CreateESRISpatialReferenceFromPRJFileExample()
    {
        //The ISpatialReferenceFactory::CreateESRISpatialReferenceFromPRJFile
        //method requires that you specify the path and filename of the PRJ
        //file you wish to import to create a spatial reference from.
        // use activator class with SpatialReferenceEnvironment singleton
        Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
        System.Object obj = Activator.CreateInstance(factoryType);
        ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3;
        ISpatialReference spatialReference = spatialReferenceFactory.
        CreateESRISpatialReferenceFromPRJFile("C:\\Program Files\\ArcGIS\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj");
    }

2.3.3 ISpatialReferenceFactory.CreateGeoTransformation

public ITransformation CreateGeoTransformation (
    intgTransformationType);

 参数由esriSRGeoTransformationTypeesriSRGeoTransformation2Type, or esriSRGeoTransformation3Type枚举器指定的变换类型,以创建特定的地理变换

ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
//Create a geographic (datum) transformation using the predefined geographic
//transformations. These can be found in the esriGeometry esriSRGeoTransformationType and esriSRGeoTransformation2Type enumerations.
IGeoTransformation geoTransformation = spatialReferenceFactory.CreateGeoTransformation((int)esriSRGeoTransformation2Type.esriSRGeoTransformation_NAD_1983_TO_HARN_MO) as IGeoTransformation;

2.3.4 ISpatialReferenceFactory.CreateParameter

public IParameter CreateParameter (int parameterType);

从 esriSRParameterTypeesriSRParameter2TypeesriSRParameter3Type, or esriSRParameter4Type 枚举器指定的参数类型,来创建指定的参数

ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); // Declare an array of IParameters, and for each, create the required Parameter object
// by using ISpatialReferenceFactory::CreateParamater. Then assign the parameter a value. Below is an example used for a Transverse Mercator projection
IParameter[] parameterArray = new IParameter[5];
parameterArray[0] = spatialReferenceFactory.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseEasting);
parameterArray[0].Value = 500000;
parameterArray[1] = spatialReferenceFactory.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseNorthing);
parameterArray[1].Value = 0;
parameterArray[2] = spatialReferenceFactory.CreateParameter((int)esriSRParameterType.esriSRParameter_CentralMeridian);
parameterArray[2].Value = -123;
parameterArray[3] = spatialReferenceFactory.CreateParameter((int)esriSRParameterType.esriSRParameter_LatitudeOfOrigin);
parameterArray[3].Value = 0;
parameterArray[4] = spatialReferenceFactory.CreateParameter((int)esriSRParameterType.esriSRParameter_ScaleFactor);
parameterArray[4].Value = 0.9996;

2.3.5 ISpatialReferenceFactory.CreatePredefinedPrimeMeridians

private void PrintPrimeMeridian()
    {
        // use activator class with SpatialReferenceEnvironment singleton
        Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
        System.Object obj = Activator.CreateInstance(factoryType);
        ISpatialReferenceFactory spatialReferenceFactory = obj as ISpatialReferenceFactory;
        ISet primeMeridiansSet = spatialReferenceFactory.CreatePredefinedPrimeMeridians();
        System.Windows.Forms.MessageBox.Show("Number of projections = " + primeMeridiansSet.Count);
        for (int i = 0; i < primeMeridiansSet.Count; i++)
        {
            IPrimeMeridian primeMeridian = primeMeridiansSet.Next() as IPrimeMeridian;
            System.Windows.Forms.MessageBox.Show(primeMeridian.Name);
        }
    }

2.3.6 ISpatialReferenceFactory.CreatePredefinedProjections

//This example shows how the CreatePredefinedProjections function returns a 
//set that contains all the available Projection objects. The set is iterated 
//through, and the name of each Projection with the set is obtained. These  
//type of functions are useful for developers who may wish to populate a 
//pulldown selection list of available SpatialReference objects. 

private void PrintProjections()
{
  ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
  ISet projectionSet = spatialReferenceFactory.CreatePredefinedProjections();
  System.Windows.Forms.MessageBox.Show("Number of projections = " + projectionSet.Count);
  for (int i = 0; i < projectionSet.Count; i++)
  {
    IProjection projection = projectionSet.Next() as IProjection;
    System.Windows.Forms.MessageBox.Show(projection.Name);
  }
}

2.3.7 ISpatialReferenceFactory.CreatePrimeMeridian

public IPrimeMeridian CreatePrimeMeridian (int primeMeridianType);

Use an element from the esriSRPrimeMType or esriSRPrimeM2Type enumerations as the primeMeridianType to create a particular predefined prime meridian.

 ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
//Create the prime meridian using the available prime meridians. These can be
//found in the esriGeometry esriSRPrimeMType enumeration.
IPrimeMeridian primeMeridian = spatialReferenceFactory.CreatePrimeMeridian((int)esriSRPrimeMType.esriSRPrimeM_Greenwich);

2.3.8 ISpatialReferenceFactory.CreateProjection

public IProjection CreateProjection (int projectionType);

Use an element from the esriSRProjectionTypeesriSRProjection2TypeesriSRProjection3Type, or esriSRProjection4Type enumerations as the projectionType to create a particular predefined map projection.

            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            //Create a projections using the available projections. These can be
            //found in the esriGeometry esriSRProjectionType, esriSRProjection2Type,
            //esriSRProjection3Type, and esriSRProjection4Type enumerations.
            IProjection projection = spatialReferenceFactory.CreateProjection((int)esriSRProjectionType.esriSRProjection_LambertConformalConic);

2.3.9 ISpatialReferenceFactory.CreateSpheroid

public ISpheroid CreateSpheroid (int spheroidType);

Use an element from the esriSRSpheroidType or esriSRSpheroid2Type enumerations as the spheroidType to create a particular predefined spheroid.

            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            //Create the spheroid using the available spheroids. These can be
            //found in the esriGeometry esriSRSpheroidType enumeration.
            ISpheroid spheroid = spatialReferenceFactory.CreateSpheroid((int)esriSRSpheroidType.esriSRSpheroid_Clarke1866);

2.3.10 ISpatialReferenceFactory.CreateUnit

public IUnit CreateUnit (int unitType);

Use an element from the esriSRUnitType or esriSRUnit2Type enumerations as the unitType to create a particular predefined unit of measure.

Use an element from the esriSRUnitType or esriSRUnit2Type enumerations as the unitType to create a particular predefined unit of measure.
ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
//Create the unit using the available units.  These can be
//found in the esriGeometry esriSRUnitType enumeration.
ILinearUnit linearUnit = spatialReferenceFactory.CreateUnit((int)esriSRUnitType.esriSRUnit_Foot) as ILinearUnit;

2.3.11 ISpatialReferenceFactory.ExportESRISpatialReferenceToPRJFile

public void ExportESRISpatialReferenceToPRJFile (
    stringprjFile,
    ISpatialReferenceSpatialReference);

ExportESRISpatialReferenceToPRJFile converts an ArcGIS style spatial reference into the well-known text string. Here is an example (reformatted):

GEOGCS["GCS_North_American_1983", DATUM["D_North_American_1983", SPHEROID["GRS_1980",6378137,298.257222101]], PRIMEM["Greenwich",0], UNIT["Degree",0.0174532925199433]]

public void ExportESRISpatialReferenceToPRJFileExample()
    {
        //The ISpatialReferenceFactory::ExportESRISpatialReferenceToPRJFile
        //method requires that you specify the path and filename of the output
        //PRJ file you wish to create with the export. A valid spatial reference
        //object containing spatial reference information is also required.
        // use activator class with SpatialReferenceEnvironment singleton
        Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
        System.Object obj = Activator.CreateInstance(factoryType);
        ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3;
        IProjectedCoordinateSystem projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_WGS1984UTM_10N);
        //Export the pcs to a prj file
        String fileName = "c:\\temp\\utm10.prj";
        spatialReferenceFactory.ExportESRISpatialReferenceToPRJFile(fileName, projectedCoordinateSystem);
    }

2.4 ISpatialReferenceFactory.CreateProjectedCoordinateSystem

2.4.1 创建投影坐标系

示例代码1:

private void CreateProjectedCoordinateSystem()
        {
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            //Create a projected coordinate system using the available projected coordinate systems
            IProjectedCoordinateSystem projectedCoordinateSystem1 = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_World_Mercator);
            //Here is an more detailed example for creating a pre-defined projected coordinate system for a new Shapefile using the 'ISpatialReferenceFactory::CreateProjectedCoordinateSystem method
            //Create the pre-defined projected coordinate system object
            IProjectedCoordinateSystem projectedCoordinateSystem2 = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983SPCS_TXSouthCentFT);
            ISpatialReference spatialReference = projectedCoordinateSystem2 as ISpatialReference;
            //Set the false origin and units for the spatial reference.
            //You can use either the Domain or the FalseOriginAndUnits methods.
            // spatialReference.SetFalseOriginAndUnits(0, 0, 0);
            spatialReference.SetDomain(-1000000, 10000000, -1000000, 10000000);
            // spatialReference.SetMDomain(0, 1);
            spatialReference.SetMFalseOriginAndUnits(1, 1);
            // spatialReference.SetZDomain(0, 1);
            spatialReference.SetZFalseOriginAndUnits(1, 1);
            // Create a new SDE workspace
            IWorkspaceFactory sdeWorkspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            IWorkspace workspace = sdeWorkspaceFactory.OpenFromFile("C:\\Documents and Settings\\bast5010\\Application Data\\ESRI\\ArcCatalog\\Connection to Vampire.sde", 0);
            IFeatureWorkspace sdeFeatureWorkspace = workspace as IFeatureWorkspace;
            //Create the fields for the feature dataset
            IFields fields = new FieldsClass();
            IFieldsEdit fieldsEdit = fields as IFieldsEdit;
            IField field = new FieldClass();
            IFieldEdit fieldEdit = field as IFieldEdit;
            fieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            fieldEdit.IsNullable_2 = false;
            fieldEdit.Name_2 = "OID";
            fieldsEdit.AddField(fieldEdit);
            IGeometryDefEdit geometryDefEdit = new GeometryDefClass();
            geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            geometryDefEdit.GridCount_2 = 1;
            geometryDefEdit.set_GridSize(0, 1000);
            geometryDefEdit.SpatialReference_2 = spatialReference;
            fieldEdit = new FieldClass();
            fieldEdit.Name_2 = "Shape";
            fieldEdit.IsNullable_2 = true;
            fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            fieldEdit.GeometryDef_2 = geometryDefEdit;
            fieldsEdit.AddField(fieldEdit);
            fieldEdit = new FieldClass();
            fieldEdit.Name_2 = "Test_Field";
            fieldEdit.IsNullable_2 = true;
            fieldEdit.Editable_2 = true;
            fieldEdit.Length_2 = 25;
            fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
            fieldsEdit.AddField(fieldEdit);
            //Create a UID for the CreateFeatureClass method
            UID uid = new UIDClass();
            uid.Generate();
            //Create ExtCLSID as for CreateFeatureClass method
            UID uidExt = new UIDClass();
            uidExt.Generate();
            //Create the feature class for the feature dataset
            IFeatureClass featureClass = sdeFeatureWorkspace.CreateFeatureClass("PreDef_StateNAD83", fields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
            System.Windows.Forms.MessageBox.Show("Data Creation Complete", "Program Status");
        }

代码示例2:

private void CreateProjectedCoordinateSystem()
{
    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
    System.Object obj = Activator.CreateInstance(t);
    ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory;
    // Use the enumeration to create an instance of the predefined object.
    IProjectedCoordinateSystem projectedCS = srFact.CreateProjectedCoordinateSystem(
        (int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_11N);
}

2.4.2  创建一个自定义的投影坐标系

private IProjectedCoordinateSystem CreateProjectedCoordinateSystem()
{

    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type factoryType = Type.GetTypeFromProgID(
        "esriGeometry.SpatialReferenceEnvironment");
    System.Object obj = Activator.CreateInstance(factoryType);
    ISpatialReferenceFactory3 spatialReferenceFactory = obj as
        ISpatialReferenceFactory3;

    // Create a projection, GeographicCoordinateSystem, and unit using the factory.
    IProjectionGEN projection = spatialReferenceFactory.CreateProjection((int)
        esriSRProjectionType.esriSRProjection_Sinusoidal)as IProjectionGEN;
    IGeographicCoordinateSystem geographicCoordinateSystem =
        spatialReferenceFactory.CreateGeographicCoordinateSystem((int)
        esriSRGeoCSType.esriSRGeoCS_WGS1984);
    ILinearUnit unit = spatialReferenceFactory.CreateUnit((int)
        esriSRUnitType.esriSRUnit_Meter)as ILinearUnit;

    // Get the default parameters from the projection.
    IParameter[] parameters = projection.GetDefaultParameters();

    // Create a PCS using the Define method.
    IProjectedCoordinateSystemEdit projectedCoordinateSystemEdit = new
        ProjectedCoordinateSystemClass();
    object name = "Newfoundland";
    object alias = "NF_LAB";
    object abbreviation = "NF";
    object remarks = "Most Eastern Province in Canada";
    object usage = "When making maps of Newfoundland";
    object geographicCoordinateSystemObject = geographicCoordinateSystem as object;
    object unitObject = unit as object;
    object projectionObject = projection as object;
    object parametersObject = parameters as object;


    projectedCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref
        remarks, ref usage, ref geographicCoordinateSystemObject, ref unitObject,
        ref projectionObject, ref parametersObject);
    return projectedCoordinateSystemEdit as IProjectedCoordinateSystem;
}

3 其它接口

3.1 IPRJSpatialReference 

 方法描述备注
 ExportSpatialReferenceToPRJExports the spatial reference to a buffer.导出参考信息
 ImportSpatialReferenceFromPRJDefines the spatial reference from the specified ESRISpatialReference buffer.从prj文件导入参考信息
 PRJSpatialReferenceSizeThe number of bytes required to hold the persistant representation of the spatial reference.pdj文件所需的字节数

A sample represetation (reformatted for display) is below.

Projection    UTM   
Zone          10  
Datum         NAD83     
Zunits        NO     
Units         METERS     
Spheroid      GRS1980     
Xshift        0.0000000000     
Yshift        0.0000000000  
Parameters  

3.2 ISpatialReferenceInfo 

属性/方法描述备注
AbbreviationThe abbreviated name of this spatial reference component.该空间参考组件的缩写名称
AliasThe alias of this spatial reference component.该空间参考组件的缩写别名
FactoryCodeThe factory code (WKID) of the spatial reference.该空间参考组件的工厂代码
NameThe name of this spatial reference component.该空间参考组件的名称
RemarksThe comment string of this spatial reference component.该空间参考组件的建议字符串

 

  • 7
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: 基于C#ArcEngine二次开发是一种利用ArcGIS Engine开发工具和C#编程语言来实现GIS应用程序的方法ArcEngine是一种基于组件的GIS开发平台,它提供了一系列的API和工具,可以帮助开发人员快速构建高效、灵活、可定制的GIS应用程序。C#是一种面向对象的编程语言,它具有简单易学、语法清晰、可读性强等特点,非常适合用于GIS应用程序的开发。基于C#ArcEngine二次开发可以实现各种功能,如地图显示、数据查询、空间分析、地图制图等,可以广泛应用于各种领域,如城市规划、土地利用、环境保护、资源管理等。 ### 回答2: ++的编程语言,它有什么优点? C++ 是一种功能强大的编程语言,它几乎拥有 C 语言所有的优点,还可以在面向对象编程方面提供更高效和灵活的方式。下面是 C++ 的几个主要优点: 1. 高效性:C++ 是一种高效的编程语言。与其他编程语言相比,C++ 的执行速度更快,它使用了更少的内存和 CPU 周期,因此可以为需要高性能的应用程序提供更好的支持。 2. 跨平台性:C++ 的编译器可以运行在许多平台上,包括 Windows、MacOS、Linux、Android 和 iOS 等。这使得 C++ 成为一种支持跨平台开发的编程语言,具有极高的灵活性和可扩展性。 3. 面向对象编程:C++ 的面向对象编程能力非常强大。它支持多态、继承和封装等特性,使得面向对象编程更加容易和灵活。 4. 库管理:C++ 提供了许多强大的库,使得开发人员可以轻松地访问各种常用功能,例如文件 I/O、字符串处理、图形界面等。这些库可以大大提高开发人员的效率,减少重复劳动。 5. 可扩展性:C++ 还具有很高的可扩展性。开发人员可以使用 C++ 来编写模块、插件和扩展程序,以满足特定的需求。此外,C++ 还提供了丰富的 API,使得开发人员可以在其程序中使用其他编程语言和技术。 总的来说,C++ 是一种功能强大、高效、跨平台、面向对象、可扩展的编程语言。它在许多行业和领域中都有广泛的应用,例如游戏开发、嵌入式系统、图形界面等。对于需要高性能和高可靠性的应用程序开发来说,C++ 是一种不错的选择。 ### 回答3: 语言的网络编程的特点是什么? C语言作为一种高效、简洁、可移植的编程语言,在网络编程中也有一定的应用。C语言基于网络编程的特点主要有以下几个方面: 1.底层控制:C语言网络编程的一个重要特点是可以对网络协议的底层进行直接控制,比如可以进行原始套接字编程。这种方式可以对网络数据包进行非常细致的处理和控制,使网络程序能够更好地适应各种各样的网络环境。 2.高效性:C语言是一种高效的编程语言,它可以为网络应用程序提供高效的性能。C语言可以通过优化算法和数据结构,降低网络应用程序的延迟和响应时间,提高网络应用程序的吞吐量,保证网络的快速响应。 3.可移植性:C语言是一种可移植的编程语言,可以在多种平台上进行开发和编译。因此,使用C语言开发网络应用程序能够保证程序在不同的操作系统和硬件平台上都能够正常运行。 4.丰富的库函数:C语言提供了丰富的库函数,可以在网络编程中提供各种功能的支持。比如可以通过各种库函数实现TCP/UDP套接字编程、服务器端编程、客户端编程、线程编程等各种网络编程功能。 总之,C语言在网络编程中具有非常重要的地位。C语言网络编程的特点主要包括底层控制、高效性、可移植性和丰富的库函数。这些特点使得C语言成为网络编程开发者的首选语言之一。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小薛引路

喜欢的读者,可以打赏鼓励一下

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值