SlideShare a Scribd company logo
Using line-based Voronoi
diagrams in GIS
Fabien Ancelin
2016, Apr 21st
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
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.
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
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.
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.
Example
Good data Bad data (small overlap)
From the Sample WPF App in SharpBoostVoronoi:
https://github.com/fabanc/SharpBoostVoronoi/tree/master/SharpBoostVoronoi/SampleWPFApp
Building a graph with integers (no scale
factor):
Introducing scale factor:
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
Output type: vertices
Vertices
X (double precision) The X coordinate
Y (double precision) The Y coordinate.
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
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.
Code sample (C#)
Draw curvy segments
Demo!
Let’s use some real GIS data!
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!

More Related Content

Using line-based Voronoi cells in GIS

  • 1. Using line-based Voronoi diagrams in GIS Fabien Ancelin 2016, Apr 21st
  • 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
  • 8. Building a graph with integers (no scale factor):
  • 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
  • 11. Output type: vertices Vertices X (double precision) The X coordinate Y (double precision) The Y coordinate.
  • 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.
  • 16. Demo! Let’s use some real GIS data!
  • 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!