WKB geometry - Well-Known Binary
Contents
[
Hide
]
Aspose.GIS C# Library will let you work with the Well-Known Binary (WKB) representation of the geometry.
Translate Geometry from WKB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |