NetTopologySuite Geometry&WKT&WKB&GeoJSON互转
作者:互联网
WKT To WKB
private static byte[] ConvertWKTToWKB(string wkt) { WKBWriter writer = new WKBWriter(); WKTReader reader = new WKTReader(); var wkb = writer.Write(reader.Read(wkt)); return wkb; }
WKB To WKT
private static string ConvertWKBToWKT(byte[] wkbBytes) { WKBReader reader = new WKBReader(); WKTWriter writer = new WKTWriter(); var wktText = writer.Write(reader.Read(wkbBytes)); return wktText; }
WKT To Geometry
WKTReader reader = new WKTReader(); NetTopologySuite.Geometries.Geometry geom = reader.Read(WKTText);
Geometry To WKT
WKTWriter writer = new WKTWriter(); var wkt = writer.Write(geo);
GeoJSON To Geometry
//引用NetTopologySuite.IO.GeoJSON //https://github.com/NetTopologySuite/NetTopologySuite.IO.GeoJSON GeoJsonReader reader = new GeoJsonReader(); var geometry = reader.Read(geoJSONText);
WKB To Geometry
WKBReader reader = new WKBReader(); NetTopologySuite.Geometries.Geometry geom = reader.Read(wkbBytes);
Geometry To WKB
WKBWriter writer = new WKBWriter(); var bytes= writer.Write(geo);
示例代码
参考资料
标签:WKB,Geometry,writer,Read,NetTopologySuite,reader,互转,new 来源: https://blog.51cto.com/u_15180952/2732706