ArcGIS Explorer Component Help |
CoordinateSystem..::.ImportFromPrjString Method |
CoordinateSystem Class Example See Also |
Creates a CoordinateSystem from a string representation of a coordinate system.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static CoordinateSystem ImportFromPrjString( string coordinateSystem ) |
Visual Basic (Declaration) |
---|
Public Shared Function ImportFromPrjString ( _ coordinateSystem As String _ ) As CoordinateSystem |
Parameters
- coordinateSystem
- Type: System..::.String
A string representation of a coordinate system.
Return Value
A new CoordinateSystem object with the properties specified in the string representation.Remarks
This method returns a CoordinateSystem object based on the string representation of a coordinate system
which has the same format as a projection (.prj) file; the string contains a complete definition of the
constituent parts of the coordinate system, for example the units, prime meridian and spheroid.
Examples
The code below shows how you can read a .prj file and convert this to an ArcGIS Explorer CoordinateSystem
using the ImportFromPrjString method. This code also makes use of the OpenFileDialog class in the
System.Windows.Forms namespace.
The code assumes you have imported the Geometry namespace.
CopyC#
// Use the OpenFileDialog to choose an existing .prj file. System.Windows.Forms.OpenFileDialog openPrjFile = new System.Windows.Forms.OpenFileDialog(); openPrjFile.Filter = "Prj files *.prj|*.prj"; openPrjFile.CheckFileExists = true; if (openPrjFile.ShowDialog() == DialogResult.OK) { // Read in the contents of the .prj file. System.IO.StreamReader reader = new System.IO.StreamReader(openPrjFile.FileName); string prjContents = reader.ReadToEnd(); if (!String.IsNullOrEmpty(prjContents)) { // Use the ImportFromPrjString to create a CoordinateSystem from a prj string. CoordinateSystem cs = CoordinateSystem.ImportFromPrjString(prjContents); // Now the new CoordinateSystem is ready to use. } }
CopyVB.NET
' Use the OpenFileDialog to choose an existing .prj file. Dim openPrjFile As System.Windows.Forms.OpenFileDialog = New System.Windows.Forms.OpenFileDialog() openPrjFile.Filter = "Prj files *.prj|*.prj" openPrjFile.CheckFileExists = True If openPrjFile.ShowDialog() = DialogResult.OK Then ' Read in the contents of the .prj file. Dim reader As System.IO.StreamReader = New System.IO.StreamReader(openPrjFile.FileName) Dim prjContents As String = reader.ReadToEnd() If Not String.IsNullOrEmpty(prjContents) Then ' Use the ImportFromPrjString to create a CoordinateSystem from a prj string. Dim cs As CoordinateSystem = CoordinateSystem.ImportFromPrjString(prjContents) ' Now the new CoordinateSystem is ready to use. End If End If