This document introduces line-based Voronoi diagrams and how they can be used in GIS applications. It discusses how most GIS software only supports point-based Voronoi diagrams, but the Boost library enables line-based Voronoi diagrams. It provides code examples for using Boost's Voronoi functionality with Python and C# for GIS applications. Proper preprocessing of GIS line data is discussed to avoid issues during Voronoi construction.
2. Introduction to Voronoi diagrams
Voronoi diagrams are continuous set of cells generated from an set of input
points.
Each input geometry will generate one cell that define its area of influence.
It is usually based on Euclidean distance.
Any point inside that cell is closer to the input geometry of that cell than to
any other input geometry
Used to determine
areas of influence
3. Limitation in current GIS software
Software Support point input Support line input
Esri ArcGIS Yes No
QGIS Yes No
PostGIS Yes No
Mapinfo Yes ???
What is you want to determine areas of influence of a line…
• Postal code out of a road network and buildings.
• Divide a road network into zones based on attributes.
4. Let there be Boost
Boost is a free, extensive C++ library. And there is a hidden gem..
http://www.boost.org/doc/libs/1_54_0/libs/polygon/doc/
voronoi_main.htm
5. Problems for the GIS community
Few GIS users know of to code in C++. Python is definitely more popular, and
so is .NET to a lesser extent. Here is how you can use boost Voronoi with your
favorite language:
Python: https://github.com/Voxel8/pyvoronoi
.NET (C#): https://github.com/fabanc/SharpBoostVoronoi
Those wrappers let you to use boost Voronoi library, but also give you built-in
functions to manage curvy shapes in your GIS data.
6. How to prepare your GIS data
Constraints raised by the boost Voronoi API:
Coordinates of the input points and endpoints of the input segments should be of
the integer type.
Input segments should not overlap except their endpoints.
Passing invalid data can:
Cause the Voronoi construction to freeze.
Return invalid results.
Controlling your input data quality is paramount.
7. Example
Good data Bad data (small overlap)
From the Sample WPF App in SharpBoostVoronoi:
https://github.com/fabanc/SharpBoostVoronoi/tree/master/SharpBoostVoronoi/SampleWPFApp
10. Using the output
Three primitives:
Cells …
Are made of Edges …
That are made of Vertices
Complete information about Boost
output at:
http://www.boost.org/doc/libs/1_54_0
/libs/polygon/doc/voronoi_diagram.ht
m
12. Voronoi output objects: edges
Edges
Start The index of the start vertex of this segment.
End The index of the end vertex of this segment.
IsPrimary False if the edge goes through the endpoint of the
segment site, else true.
IsLinear True is a segment is a line, false if the segment is an
arc.
IsFinite True if the edge is delimited by two known vertices,
False otherwise.
Cell The index of the cell associated with this segment
Twin The index of the twin cell associated with this
segment
13. Voronoi output objects: cells
Cells
Index The voronoi cell identifier
Site The index of the source feature
ContainsPoint True if the cell is made from a point
ContainsSegment True if the cell is made from a segment
EdgesIndex Indexes of the segment that makes the cell
IsOpen True if the cell has a segment that is infinite
SourceCategory The type of element used to create the edge.
17. Wrapping up
Any idea of what problems this could solve for you?
Any comments or questions?
If you’re working with ArcGIS, you can make a geoprocessing tool.
Thank you!