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


ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Geometry)  

ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile Method

Creates a spatial reference from a PRJ file.

[Visual Basic .NET]
Public Function CreateESRISpatialReferenceFromPRJFile ( _
    ByVal prjFile As String _
) As ISpatialReference
[C#]
public ISpatialReference CreateESRISpatialReferenceFromPRJFile (
    string prjFile
);
[C++]
HRESULT CreateESRISpatialReferenceFromPRJFile(
  BSTR prjFile,
  ISpatialReference** SpatialReference
);
[C++]

Parameters prjFile prjFile is a parameter of type BSTR SpatialReference [out, retval]
SpatialReference is a parameter of type ISpatialReference

Product Availability

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

Remarks

Both old style (workstation) and new style (ArcGIS for Desktop Basic) prj files can be used with this method to create spatial reference system objects.

[C#]

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

[Visual Basic .NET]

        '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.

        Dim pSpatRefFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory
        pSpatRefFact=New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment

        Dim pSpatRef As ESRI.ArcGIS.Geometry.ISpatialReference
        pSpatRef=pSpatRefFact.CreateESRISpatialReferenceFromPRJFile("c:\geodata\prj_import.prj")

See Also

ISpatialReferenceFactory Interface

.NET Samples

StreetMap routing (Code Files: RoutingForm)

.NET Related Topics

Constructing a high- or low-precision spatial reference | How to import or export a spatial reference | Using the SpatialReferenceEnvironment