Skip to content
Simon Bartlett edited this page Jan 26, 2013 · 2 revisions

Geo can read and write WKT (Well-known text). Geometries that implement IOgcGeometry can be read and written to WKT.

Reading

var reader = new WktReader();
IOgcGeometry point = reader.Read("POINT (73.89 68.389)"); // reading a string
IOgcGeometry geometry = reader.Read(myStream); // reading a stream

Writing

var writer = new WktWriter();
var pointString = writer.Write(new Point(68.389, 73.89));

A number of settings are available to customize the output. The code below shows their default values:

var settings = new WktWriterSettings {
			LinearRing = false;
			Triangle = false;
			DimensionFlag = true;
			NullOrdinate = Coordinate.NullOrdinate.ToString(CultureInfo.InvariantCulture);
			MaxDimesions = 4;
		};

var writer = new WktWriter(settings); // Pass the settings object into the writer's constructor

There is also static constructor, for using settings that are compatible with NTS/JTS:

var writer = new WktWriter(WktWriterSettings.NtsCompatible);
Clone this wiki locally