This document is archived and information here might be outdated. Recommended version. |
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
);
[C++] Parameters prjFile
prjFile is a parameter of type BSTR
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.
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");
}
'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")