WKB geometry - Well-Known Binary

Aspose.GIS C# Library will let you work with the Well-Known Binary (WKB) representation of the geometry.

Translate Geometry from WKB

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
string path = Path.Combine(RunExamples.GetDataDir(), "WkbFile.wkb");
byte[] wkb = File.ReadAllBytes(path);
IGeometry geometry = Geometry.FromBinary(wkb);
Console.WriteLine(geometry.AsText()); // LINESTRING (1.2 3.4, 5.6 7.8)

Translate Geometry to WKB

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
IGeometry geometry = Geometry.FromText("LINESTRING (1.2 3.4, 5.6 7.8)");
byte[] wkb = geometry.AsBinary();
//File.WriteAllBytes(Path.Combine(TestConfiguration.TestOutputPath, "file.wkb"), wkb);
File.WriteAllBytes(Path.Combine(RunExamples.GetDataDir(), "WkbFile.wkb"), wkb);

Specify WKB Variant on Translation

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
IGeometry geometry = Geometry.FromText("LINESTRING (1.2 3.4, 5.6 7.8)");
byte[] wkb = geometry.AsBinary(WkbVariant.ExtendedPostGis);
File.WriteAllBytes(Path.Combine(RunExamples.GetDataDir(), "EWkbFile.ewkb"), wkb);