How to create a custom geographic coordinate system


Summary
This article demonstrates two methods to create a user-defined geographic coordinate system.

Creating a custom geographic coordinate system

A geographic coordinate system 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 coordinate system. Latitude-longitude or lat/lon data is in a geographic coordinate system. You can access the majority of the properties and methods through the IGeographicCoordinateSystem interface with a few more properties that are available in IGeographicCoordinateSystem2. Although most developers will not need to create a custom geographic coordinate system, the IGeographicCoordinateSystemEdit contains the Define and DefineEx methods.
The following code demonstrates how to use the Define method to create a user-defined geographic coordinate system. The ISpatialReferenceFactory 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.
[Java]
static IGeographicCoordinateSystem createGeographicCoordinateSystem()throws
    Exception{
    ISpatialReferenceFactory3 spatialReferenceFactory = new
        SpatialReferenceEnvironment();
    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
        GeographicCoordinateSystem();

    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;
    Object primeMeridianObject = primeMeridian;
    Object unitObject = unit;

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

    IGeographicCoordinateSystem userDefinedGeographicCoordinateSystem = 
        (IGeographicCoordinateSystem)geographicCoordinateSystemEdit;

    return userDefinedGeographicCoordinateSystem;
}
The following Java code shows how the DefineEx method can be used. It uses a SpatialReferenceEnvironment to create the Datum, PrimeMeridian, and Unit components.
[Java]
static IGeographicCoordinateSystem createGeographicCoordinateSystemEx()throws
    Exception{
    ISpatialReferenceFactory3 spatialReferenceFactory = new
        SpatialReferenceEnvironment();
    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
        GeographicCoordinateSystem();

    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, (IAngularUnit)unit);

    IGeographicCoordinateSystem userDefinedGeographicCoordinateSystem = 
        (IGeographicCoordinateSystem)geographicCoordinateSystemEdit;

    return userDefinedGeographicCoordinateSystem;
}






Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine