This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IS > ISpatialReferenceFactory Interface > ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile Method (ArcObjects .NET 10.4 SDK) |
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,
ISpatialReference** SpatialReference
);
[C++]
Parameters prjFile prjFile is a parameter of type BSTR SpatialReference [out, retval]
SpatialReference is a parameter of type ISpatialReference
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")