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


IESRISpatialReference.ImportFromESRISpatialReference Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Geometry)  

IESRISpatialReference.ImportFromESRISpatialReference Method

Defines this spatial reference component from the specified ESRISpatialReference buffer.

[Visual Basic .NET]
Public Sub ImportFromESRISpatialReference ( _
    ByVal str As String, _
    ByRef cBytesRead As Integer _
)
[C#]
public void ImportFromESRISpatialReference (
    string str,
    ref int cBytesRead
);
[C++]
HRESULT ImportFromESRISpatialReference(
  BSTR str,
  long* cBytesRead
);
[C++]

Parameters str str is a parameter of type BSTR cBytesRead [out] cBytesRead is a parameter of type long

Product Availability

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

Description

Converts a string representation of a coordinate system into a spatial reference object. A sample string representation is below (reformatted for display).

PROJCS["Porto_Santo_1936_UTM_Zone_28N",
  GEOGCS["GCS_Porto_Santo_1936",
    DATUM["D_Porto_Santo_1936",
    SPHEROID["International_1924",6378388,297]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.0174532925199432955]],
  PROJECTION["Transverse_Mercator"],
  PARAMETER["False_Easting",500000],
  PARAMETER["False_Northing",0],
  PARAMETER["Central_Meridian",-15],
  PARAMETER["Scale_Factor",0.9996],
  PARAMETER["Latitude_Of_Origin",0],
  UNIT["Meter",1]]
[C#]

    public ISpatialReference IESRISpatialReferenceExample()
    {
        int size=-1;
        //Not Parameter keyword
        //Note also the back slash around false_easting so that the double quotation marks will read correctly
        string wktString="PROJCS[\"Test\", GEOGCS[\"GCS_WGS_1984\", DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\", 6378137, 298.257223]], PRIMEM[\"Greenwich\", 0],UNIT[\"Degree\", 0.0174532925199433]], PROJECTION[\"Mercator\"],PARAMETER[\"false_easting\", 1000000], UNIT[\"Foot\", 0.3048]]";
        //Create an ESRISpatialReference using the parameter class
        IESRISpatialReference esriSpatialReferenceProjection=new ProjectedCoordinateSystemClass() as IESRISpatialReference;
        esriSpatialReferenceProjection.ImportFromESRISpatialReference(wktString, out size);
        //Set your parameter to the one you just created
        ISpatialReference spatialReference=esriSpatialReferenceProjection as ISpatialReference;
        return spatialReference;
    }

See Also

IESRISpatialReference Interface