What is the best way to create a polygon from list of point?
I have an array of points, if points are at least 3 I would like to join to create a polygon
Dim ClickedPoint As New NetTopologySuite.Geometries.Point(coordinates)
ClickedPointArray.Add(ClickedPoint)
if ClickedPointArray.Count > 2 then
Polygonizer = New Polygonizer()
Polygonizer.Add(ClickedPointArray)
end if
return Polygonizer.GetPolygons
I think I'm very far from solution. Could you help me?
You can create a Polygon with an array of coordinates using GeometryFactory like this:
Dim coordinatesArray as Coordinate[] = YourMethodToGetCoordinates
Dim geomFactory As New GeometryFactory
Dim poly As geomFactory.CreatePolygon(coordinatesArray) //this returns an IPolygon that you can cast to Polygon
Here is the C#
Coordinate[] imageOutlineCoordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1), new Coordinate(2, 2), new Coordinate(1, 1) }; GeometryFactory geometryFactory = new GeometryFactory(); Polygon poly = geometryFactory.CreatePolygon(imageOutlineCoordinates);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With