Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

Commented Unassigned: Long time to create thiessen polygon feature on real time data [24661]

$
0
0
I'm developing a customized application using Dotspatial and as a part of it I used Voronoi tool from Dotspatial.Analysis.Voronoi. When I use sample 4-5 points then test was successful for creating Voronoi feature. But When I use a real time data for creating Voronoi, application goes into indefinite loop. I wait till 30 minute to complete the action but didn't succeed. I use following code for generating Voronoi.

Code///
IFeatureSet fs1 = new DotSpatial.Data.FeatureSet();

fs1 = (IFeatureSet)FeatureSet.Open(path1);

IFeatureSet _Result = new FeatureSet(FeatureType.Polygon);
MapPolygonLayer lineLayer;

lineLayer = (MapPolygonLayer)map1.Layers.Add(_Result);

//Create Voronoi Polygons
DotSpatial.Analysis.Voronoi.VoronoiPolygons(fs1, _Result, cropToExtent: true);
Comments: ** Comment from web user: Oscarafone77 **

Did you try using nettopologysuite?

Fobermaier suggested that to me and I could make it. Here is the code for computing voronoi diagrams from a list of coordinates (stored in two array: Xcoords and Ycoords).

```
Dim Xcoord As New List(Of Double)()
Dim Ycoord As New List(Of Double)()
Dim result As GeoAPI.Geometries.IGeometryCollection
Dim NumberOfVertices As Integer


Dim geometryFactory As GeoAPI.Geometries.IGeometryFactory = New NetTopologySuite.Geometries.GeometryFactory()
Dim builder As NetTopologySuite.Triangulate.DelaunayTriangulationBuilder

builder = New NetTopologySuite.Triangulate.DelaunayTriangulationBuilder()

Dim coords As NetTopologySuite.Geometries.CoordinateList = New NetTopologySuite.Geometries.CoordinateList()
For i As Integer = 0 To NumberOfVertices - 1
coords.Add(New Geometries.Coordinate(Xcoord(i), Ycoord(i)))
Next

builder.SetSites(coords)
Dim subdiv As NetTopologySuite.Triangulate.QuadEdge.QuadEdgeSubdivision = builder.GetSubdivision()
'QuadEdgeSubdivision<coord> subdiv = builder.GetSubdivision();
result = Nothing
'result = builder.GetEdges(geometryFactory);

result = subdiv.GetVoronoiDiagram(geometryFactory)

```

then what you get is a list of geometries, each one of which is a polygon which you have to convert to a dotspatial feature

Oscar


Viewing all articles
Browse latest Browse all 3973