Hi,
You can serialize ISpatialReference object to xml ant then read wkt from it. Code for serialization:
private static string GetSpatialReferenceAsXmlString(ISpatialReference spatialReference)
{
if (spatialReference == null) throw new ArgumentNullException("spatialReference");
var xmlStream = new XMLStreamClass();
var xmlWriter = new XMLWriterClass();
var xmlSerializer = new XMLSerializerClass();
xmlWriter.WriteTo(xmlStream);
xmlSerializer.WriteObject(xmlWriter, null, null, string.Empty, string.Empty, spatialReference);
return xmlStream.SaveToString();
}
You will get xml like this:
<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.8'>
<WKT>PROJCS["LKS_1994_Transverse_Mercator",GEOGCS["GCS_LKS_1994",DATUM["D_Lithuania_1994",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",24.0],PARAMETER["Scale_Factor",0.9998],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]</WKT>
<XOrigin>-22523120044.116333</XOrigin>
<YOrigin>-22527998119.405388</YOrigin>
<XYScale>18181.818166159173</XYScale>
<ZOrigin>-100000</ZOrigin>
<ZScale>10000</ZScale>
<MOrigin>-100000</MOrigin>
<MScale>10000</MScale>
<XYTolerance>0.001</XYTolerance>
<ZTolerance>0.001</ZTolerance>
<MTolerance>0.001</MTolerance>
<HighPrecision>true</HighPrecision>
</ProjectedCoordinateSystem>
Then read WKT node from it