How to import or export a spatial reference

Importing or exporting a spatial reference

This article shows how to create a predefined projected coordinate system (PCS), define its coordinate grid and tolerance values, then export and import it two different ways. First, it exports the coordinate system to a .prj file, then uses the contents of the .prj file to create a second PCS.
At the end of this process, you might expect that both PCSs will be identical, but they are not. PRJ files do not store coordinate grid information, so re-creating a spatial reference from a PRJ file will lose any coordinate grid and tolerance information that might have been defined for it.
Complete equality of spatial references (equal coordinate systems and equal coordinate grids) cannot be checked with one method. IClone.IsEqual compares coordinate systems but not coordinate grids. You need to use other methods to do the latter. See the following:
static void importExportSR_Example()throws Exception{
    //Instantiate a predefined spatial reference and set its coordinate grid information.
    ISpatialReferenceFactory spatialReferenceFactory = new
    IProjectedCoordinateSystem projectedCoordinateSystem =
    ISpatialReferenceResolution spatialReferenceResolution = 
    ISpatialReferenceTolerance spatialReferenceTolerance = 


    //Export the PCS to a .prj file.
    String fileName = "c:\\temp\\utm10.prj";

    //Rehydrate it as a new spatial reference object.
    ISpatialReference projectedCoordinateSystem2 =

    //See if they are equal.
    IClone comparison = (IClone)projectedCoordinateSystem;

    //Should be true, but coordinate grid information has not been checked.

    ISpatialReference2 comparePrecisions = (ISpatialReference2)

    //Should be false, PRJ files do not persist coordinate grid information.

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