Skip to content

Commit

Permalink
ver update
Browse files Browse the repository at this point in the history
  • Loading branch information
hohyon-ryu committed Aug 22, 2011
1 parent 41fea32 commit 02b5da5
Show file tree
Hide file tree
Showing 6 changed files with 661 additions and 28,625 deletions.
88 changes: 57 additions & 31 deletions README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
py_geo_voronoi
infochimps Voronoi

Created by Hohyon Ryu, Aug/19/2011
Created by Hohyon Ryu, Aug/22/2011

* Dependencies

Expand All @@ -9,6 +9,18 @@ Created by Hohyon Ryu, Aug/19/2011
- Built on Steve Fortune's Python Voronoi Code
Steve Fortune's homepage: http://netlib.bell-labs.com/cm/cs/who/sjf/index.html

* Files

README
globalmaptiles.py - Google Geo-coordinate Library
voronoi.py - Voronoi lattice library (line and vertices based)
voronoi_poly.py - Voronoi lattice library (polygon based)

sample_city_data.csv - sample data

main_example.py - code example


* Inputs:
1. Dictionary of the points: (You can use simple sequential number for the dictionary keys or some text to associate with.)
PointsMap={}
Expand All @@ -30,38 +42,52 @@ Created by Hohyon Ryu, Aug/19/2011

* Output options:
1. Stations, Lines and edges
Example:
import voronoi_poly
vl=voronoi_poly.VoronoiLineEdges(PointsMap)

Output:
vertices, lines, edges, station_to_edge
(1) a list of 2-tuples, which are the x,y coordinates of the
Voronoi diagram vertices
(2) a list of 3-tuples (a,b,c) which are the equations of the
lines in the Voronoi diagram: a*x + b*y = c
(3) a list of 3-tuples, (l, v1, v2) representing edges of the
Voronoi diagram. l is the index of the line, v1 and v2 are
the indices of the vetices at the end of the edge. If
v1 or v2 is -1, the line extends to infinity.
(4) a dictionary, where keys are the station numbers(vertices), and the
values are the number of edges surrounding the vertice.

2. Polygons
3. GeoJson Polygons
4. GeoJson MultiPolygons

Example:
import voronoi_poly

vl=voronoi_poly.VoronoiLineEdges(PointsMap)
Output:
vertices, lines, edges, station_to_edge
(1) a list of 2-tuples, which are the x,y coordinates of the
Voronoi diagram vertices
(2) a list of 3-tuples (a,b,c) which are the equations of the
lines in the Voronoi diagram: a*x + b*y = c
(3) a list of 3-tuples, (l, v1, v2) representing edges of the
Voronoi diagram. l is the index of the line, v1 and v2 are
the indices of the vetices at the end of the edge. If
v1 or v2 is -1, the line extends to infinity.
(4) a dictionary, where keys are the station numbers(vertices), and the
values are the number of edges surrounding the vertice.

vl=voronoi_poly.VoronoiPolygons(PointsMap, BoundingBox="AUSTIN", PlotMap=False)
Output:
185: {'coordinate': (3.04, 36.77), 'info': 'Algiers/Algeria', 'obj_polygon': <shapely.geometry.polygon.Polygon object at 0x3152190>}

- You can access the polygon coordinates by the following example:
import voronoi_poly
vl=voronoi_poly.VoronoiPolygons(PointsMap, BoundingBox="AUSTIN", PlotMap=False)
Output:
185: {'coordinate': (3.04, 36.77), 'info': 'Algiers/Algeria', 'obj_polygon': <shapely.geometry.polygon.Polygon object at 0x3152190>}

- You can access the polygon coordinates by the following example:

from shapely.geometry import Polygon
print list(polygon_data.exterior.coords)

from shapely.geometry import Polygon
print list(polygon_data.exterior.coords)
3. Quadkey-based Grids on Polygons
import voronoi_poly

vl=voronoi_poly.VoronoiGeoJson_Polygons(PointsMap, BoundingBox="US")
vl=voronoi_poly.VoronoiPolygons(PointsMap, BoundingBox="W", PlotMap=False)
voronoi_poly.GridVoronoi(vl, zl=7, PlotMap=True)
Output: Quadkey, Station_name, Longitude, Latitude

vl=voronoi_poly.VoronoiGeoJson_MultiPolygons(PointsMap, BoundingBox="KR")
4. GeoJson Polygons
import voronoi_poly
voronoi_poly.VoronoiGeoJson_Polygons(PointsMap, BoundingBox="US")
Output:
Geojson Polygons

5. GeoJson MultiPolygons
import voronoi_poly
voronoi_poly.VoronoiGeoJson_MultiPolygons(PointsMap, BoundingBox="KR")
Output:
Geojson MiltiPolygons



Loading

0 comments on commit 02b5da5

Please sign in to comment.