using NetTopologySuite.Geometries; using NetTopologySuite.IO; using NetTopologySuite.Operation.Distance; public double FindClosestPoint(string wktA, string wktB) { double distance = 0; var fact = new GeometryFactory(); var wktRdr = new WKTReader(fact); Debug.WriteLine("-------------------------------------"); try { var A = wktRdr.Read(wktA); var B = wktRdr.Read(wktB); Debug.WriteLine("Geometry A: " + A); Debug.WriteLine("Geometry B: " + B); var distOp = new DistanceOp(A, B); distance = distOp.Distance(); Debug.WriteLine($"Distance = {distance}"); //var closestPt = distOp.NearestPoints(); //var closestPtLine = fact.CreateLineString(closestPt); //Debug.WriteLine("Closest points: " + closestPtLine + " (distance = " + closestPtLine.Length + ")"); } catch (Exception ex) { throw ex; } return distance; }