This document is archived and information here might be outdated.  Recommended version.


ISpatialReferenceFactory.CreateProjectedCoordinateSystem Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IS > ISpatialReferenceFactory Interface > ISpatialReferenceFactory.CreateProjectedCoordinateSystem Method
ArcGIS Developer Help

ISpatialReferenceFactory.CreateProjectedCoordinateSystem Method

Creates a predefined projected coordinate system.

[Visual Basic .NET]
Public Function CreateProjectedCoordinateSystem ( _
    ByVal pcsType As Integer _
) As IProjectedCoordinateSystem
[C#]
public IProjectedCoordinateSystem CreateProjectedCoordinateSystem (
    int pcsType
);
[C++]
HRESULT CreateProjectedCoordinateSystem(
  long pcsType
);
[C++]
Parameters
pcsType 

pcsType is a parameter of type long

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Use an element from the esriSRProjCSType, esriSRProjCS2Type, esriSRProjCS3Type, or esriSRProjCS4Type enumerations as the pcsType to create a particular predefined projected coordinate system.

[C#]

        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");
        }

[Visual Basic .NET]

    Private Sub CreateProjectedCoordinateSystem()
        Dim pSpatRefFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory
        'Set the spatial reference factory to a new spatial reference environment
        pSpatRefFact = New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment
        Dim pProjCoordSys As ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem
        'Create a projected coordinate system using the available projected coordinate systems
        pProjCoordSys = pSpatRefFact.CreateProjectedCoordinateSystem(ESRI.ArcGIS.Geometry.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

        pProjCoordSys = pSpatRefFact.CreateProjectedCoordinateSystem(ESRI.ArcGIS.Geometry.esriSRProjCSType.esriSRProjCS_NAD1983SPCS_TXSouthCentFT)
        Dim pSpatRef As ESRI.ArcGIS.Geometry.ISpatialReference
        pSpatRef = pProjCoordSys
        'Set the domain extents for the new dataset
        pSpatRef.SetDomain(-10000000, 10000000, -10000000, 10000000)
        'pSpatRef.SetFalseOriginAndUnits 0, 0, 0
        pSpatRef.SetMDomain(1, 1)
        'pSpatRef.SetMFalseOriginAndUnits 1, 1
        pSpatRef.SetZDomain(0, 1)
        'pSpatRef.SetZFalseOriginAndUnits 1, 1
        'Create a new SDE workspace
        Dim pSdeWorkspaceFactory As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory
        pSdeWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory
        Dim pWorkspace As ESRI.ArcGIS.Geodatabase.IWorkspace
        pWorkspace = pSdeWorkspaceFactory.OpenFromFile("C:\\Documents and Settings\\bast5010\\Application Data\\ESRI\\ArcCatalog\\Connection to Vampire.sde", 0)
        Dim pSdeFeatureWorkspace As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace
        pSdeFeatureWorkspace = pWorkspace
        'Creat the fields for new dataset
        Dim pFlds As ESRI.ArcGIS.Geodatabase.IFields
        pFlds = New ESRI.ArcGIS.Geodatabase.Fields
        Dim pFldsEdit As ESRI.ArcGIS.Geodatabase.IFieldsEdit
        pFldsEdit = pFlds
        Dim pFld As ESRI.ArcGIS.Geodatabase.IField
        pFld = New ESRI.ArcGIS.Geodatabase.Field
        Dim pFldEdit As ESRI.ArcGIS.Geodatabase.IFieldEdit
        pFldEdit = pFld
        With pFldEdit
            .Type_2 = 6
            .IsNullable_2 = False
            .Name_2 = "OID"
        End With
        pFldsEdit.AddField(pFldEdit)
        Dim pGeodef As ESRI.ArcGIS.Geodatabase.IGeometryDefEdit
        pGeodef = New ESRI.ArcGIS.Geodatabase.GeometryDef
        With pGeodef
            .GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon
            .GridCount_2 = 1
            .GridSize_2(0) = 1000


            .SpatialReference_2 = pSpatRef
        End With
        pFldEdit = New ESRI.ArcGIS.Geodatabase.Field
        With pFldEdit
            .Name_2 = "Shape"
            .IsNullable_2 = True
            .Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry
            .GeometryDef_2 = pGeodef
        End With
        pFldsEdit.AddField(pFldEdit)
        pFldEdit = New ESRI.ArcGIS.Geodatabase.Field
        With pFldEdit
            .Name_2 = "Test_Field"
            .Editable_2 = True
            .Length_2 = 25
            .Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString
        End With
        pFldsEdit.AddField(pFldEdit)
        Dim pUID As New ESRI.ArcGIS.esriSystem.UID
        pUID.Generate()
        Dim pEXTCLSID As New ESRI.ArcGIS.esriSystem.UID
        pEXTCLSID.Generate()
        Dim shapeFieldName As String
        shapeFieldName = "Shape"
        Dim pOutputFeatureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
        'Create the feature class
        pOutputFeatureClass = pSdeFeatureWorkspace.CreateFeatureClass("PreDef_StateNAD83", pFlds, Nothing, Nothing, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, "Shape", "")
        MsgBox("Data Creation Complete", vbOKOnly, "Program ")
    End Sub

See Also

ISpatialReferenceFactory Interface | esriSRProjCSType Constants | esriSRProjCS2Type Constants | esriSRProjCS3Type Constants | esriSRProjCS4Type Constants

.NET Samples

Create a Mosaic dataset Create a custom raster type Create a custom raster type from the ground up for DMCII data Geoevents in a MapControl