Skip to content

Instantly share code, notes, and snippets.

@samerlahoud
Last active October 7, 2017 21:33
Show Gist options
  • Save samerlahoud/ad5415874e0405576ebe8101244cbfd9 to your computer and use it in GitHub Desktop.
Save samerlahoud/ad5415874e0405576ebe8101244cbfd9 to your computer and use it in GitHub Desktop.
#!/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