码迷,mamicode.com
首页 > Web开发 > 详细

NetTopologySuite Geometry&WKT&WKB&GeoJSON互转

时间:2020-04-22 20:17:36      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:return   aml   net   text   gis   pre   reader   wpf   代码   

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);

GeoJSON To Geometry

//引用NetTopologySuite.IO.GeoJSON
//https://github.com/NetTopologySuite/NetTopologySuite.IO.GeoJSON
GeoJsonReader reader = new GeoJsonReader();
var geometry = reader.Read<NetTopologySuite.Geometries.Geometry>(geoJSONText);

WKB To Geometry

WKBReader reader = new WKBReader();
NetTopologySuite.Geometries.Geometry geom = reader.Read(wkbBytes);

示例代码

ConvertDataWindow

NetTopologySuite Geometry&WKT&WKB&GeoJSON互转

标签:return   aml   net   text   gis   pre   reader   wpf   代码   

原文地址:https://www.cnblogs.com/Lulus/p/12751792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!