Last active
October 7, 2017 21:33
-
-
Save samerlahoud/ad5415874e0405576ebe8101244cbfd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
### Samer Lahoud http://samer.lahoud.fr | |
import json | |
import os | |
import matplotlib.pyplot as plt | |
from scipy.spatial import Voronoi, voronoi_plot_2d | |
import numpy as np | |
import mplleaflet | |
# Load up the geojson data | |
filename = ('buildings.geojson') | |
with open(filename) as f: | |
gj = json.load(f) | |
# Grab the coordinates (longitude, latitude) from the features, which we | |
# know are Points | |
xy = np.array([feat['geometry']['coordinates'] for feat in gj['features']]) | |
vor_polygon = Voronoi(xy) | |
voronoi_plot_2d(vor_polygon, show_vertices = False) | |
mapfile = 'ixp-voronoi-cells.html' | |
# Create the map. Save the file to html | |
mplleaflet.show(path=mapfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment