Constructing a Coordinate System (CS) by Well-known Text (WKT)

string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";
ICoordinateSystem cs = SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt) as ICoordinateSystem;

If you know that the WKT is for instance a geographic coordinate system as above, you can instead cast it to that if necessary:
IGeographicCoordinateSystem gcs = CoordinateSystemWktReader.Parse(wkt_geo) as IGeographicCoordinateSystem;

and similar for a projected coordinate system:
IProjectedCoordinateSystem pcs = CoordinateSystemWktReader.Parse(wkt_proj) as IProjectedCoordinateSystem;

Last edited Oct 4, 2007 at 5:14 AM by SharpGIS, version 1


No comments yet.