How to retrieve projected coordinate system info

286
4
04-08-2020 01:58 AM
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Guys,

I am currently migrating the ArcMap extension to ArcGIS pro extension for my client.

I currently cannot figure out how to get information of projected coordinate system such as central meridian, scale factor similar to arcobject IProjectedCoordinateSystem Interface. Is there anyway to get these properties from ArcGIS Pro sdk spatialreference?

0 Kudos
4 Replies
GintautasKmieliauskas
Regular Contributor

HI Than,

You can parse them from json or xml string using SpatialReference methods ToXML() or ToJson()

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Gintautas Kmieliauskas‌,

I believe you are talking about ArcGIS.Core.Geometry.SpatialReference (ToJson() ) method.

For toxml call I got : 

<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/2.5.0'><WKT>PROJCS[&quot;AGD_1966_AMG_Zone_50&quot;,GEOGCS[&quot;GCS_Australian_1966&quot;,DATUM[&quot;D_Australian_1966&quot;,SPHEROID[&quot;Australian&quot;,6378160.0,298.25]],PRIMEM[&quot;Greenwich&quot;,0.0],UNIT[&quot;Degree&quot;,0.0174532925199433]],PROJECTION[&quot;Transverse_Mercator&quot;],PARAMETER[&quot;False_Easting&quot;,500000.0],PARAMETER[&quot;False_Northing&quot;,10000000.0],PARAMETER[&quot;Central_Meridian&quot;,117.0],PARAMETER[&quot;Scale_Factor&quot;,0.9996],PARAMETER[&quot;Latitude_Of_Origin&quot;,0.0],UNIT[&quot;Meter&quot;,1.0],AUTHORITY[&quot;EPSG&quot;,20250]]</WKT><XOrigin>-5120900</XOrigin><YOrigin>1800</YOrigin><XYScale>10000</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTol
erance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>20250</WKID><LatestWKID>20250</LatestWKID></ProjectedCoordinateSystem>

For ToJson() method call I got:
"{\"wkid\":20250,\"latestWkid\":20250}"

For example: If I want central meridian or to check that pcs is Transverse Mercator, I currently need to parse wkt string and get manually at the moment, I can't find build in specific properties at that moment yet.

Or is that in ArcGIS.core.Internal library?..

0 Kudos
GintautasKmieliauskas
Regular Contributor

Hi Than,

For ArcGIS.Core.Geometry.SpatialReference you can use ToXML() method ang then deserialize result string to ProjectedCoordinateSystem or GeographicCoordinateSystem (depending on your spatial reference). Then take from coordinate system variable WKT property. For ArcGIS.core.Internal.CIM.SpatialReference you can just take wkt property.

WKT parser you can find on internet. First what I find :

GitHub - Esri/ogc-crs-wkt-parser: Sample code to implement new OGC WKT specification 

ThanHtetAung_EsriAu
Esri Regular Contributor

Thank Gintautas Kmieliauskas‌ for your info

Parsing the wkt string is what I am currently doing at the moment. I managed to get these value with regex easily at the moment.

Look like my question is not quite clear.

I want to know whether is there easy way to retrieve those value like how we are able to get from arcobject PCS class library.

Anyway, it seem, these two sdks are quite different.

0 Kudos