ArcObjects Library Reference (Geometry)  

ISpatialReferenceFactory.ExportESRISpatialReferenceToPRJFile Method

Exports a spatial reference to a PRJ file.

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

Parameters

prjFile   prjFile is a parameter of type BSTR SpatialReference

  SpatialReference is a parameter of type ISpatialReference

Product Availability

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

Description

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]]

 

Remarks

To convert a spatialreference into an ArcInfo workstation format (for TINs, GRIDs, or coverages), use  IPRJSpatialReferenceGEN_ExportSpatialReferenceToPRJ.

[C#]

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

[Visual Basic .NET]

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

        'pSpatRefFact represents an ISpatialReferenceFactory object
        'pSpatRef represents an ISpatialReference object

        pSpatRefFact.ExportESRISpatialReferenceToPRJFile("c:\geodata\prj_export", pSpatRef)

See Also

ISpatialReferenceFactory Interface