When developing under ArcMap, we used to be able to create a spatialreference from a prj file just like in this example:
pSpatialReference = pSRFact.CreateESRISpatialReferenceFromPRJFile(_sPrjFile);
But when I look at the documentation for ArcGIS Pro SDK, I only see that in order to create a spatial reference, the most common way of doing it is using a wkid number.
Can I do it using a prj file, or am I missing something here?
Solved! Go to Solution.
Hi ,
We don't have anything to use the prj file directly, but I believe you should be able to use the following code as the prj file contains text in the wkt format. I have wrapped the CreateSpatialReference call in a try/catch in case of error which would need to be handled.
try
{
string path = @"c:\60571.prj";
var sText = System.IO.File.ReadAllText(path);
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(sText);
}
catch (Exception e)
{
}
Regards
Narelle
Hi ,
We don't have anything to use the prj file directly, but I believe you should be able to use the following code as the prj file contains text in the wkt format. I have wrapped the CreateSpatialReference call in a try/catch in case of error which would need to be handled.
try
{
string path = @"c:\60571.prj";
var sText = System.IO.File.ReadAllText(path);
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(sText);
}
catch (Exception e)
{
}
Regards
Narelle
Thanks a lot Narelle. It will work for me.