Skip to content

Instantly share code, notes, and snippets.

View jwass's full-sized avatar

Jacob Wasserman jwass

View GitHub Profile
@jwass
jwass / converted.geojson
Last active December 17, 2015 22:33
Example script using Pandas/GeoPandas to help @jqtrde. See https://gist.github.com/jacquestardie/ba32c3304bbe7d8e85b5
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jwass
jwass / delaunay.py
Last active February 27, 2019 13:42
Example using proposed Delaunay triangulation method in Shapely
import matplotlib.pyplot as plt
import numpy as np
from shapely.geometry import LineString
from shapely.ops import triangulate
def uniform_sample(poly, n=100):
"""
Uniformly sample the Delaunay triangulation of a polygon. If the polygon
is convex, this will uniformly sample its area.
@jwass
jwass / lights.geojson
Created May 8, 2014 15:12
Cambridge Traffic Lights in OSM
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jwass
jwass / boston_marathon.geojson
Created April 20, 2014 17:04
Boston Marathon Route GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jwass
jwass / cambridge_raw_osm.geojson
Last active April 11, 2016 04:12
Demonstrate using GeoPandas and geojsonio.py (http://github.com/jwass/geojsonio.py) to view styled data in a few lines. Running the script will open a browser with the final URL: http://geojson.io/#id=gist:/10218442
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jwass
jwass / contactinfo.py
Created August 25, 2013 18:08
Scrape MA state senate/representative contact info and merge it with the legislator's property info.
import difflib
import json
import re
import bs4
import pandas as pd
import requests
regex = re.compile('\((.*)\)')
@jwass
jwass / convert.py
Created August 15, 2013 21:52
Simple Shapefile to GeoJSON converter. Using the shapefile from here: http://www.mass.gov/anf/research-and-tech/it-serv-and-support/application-serv/office-of-geographic-information-massgis/datalayers/senate2012.html it will result in an error "ValueError: Record's geometry type does not match collection schema's geometry type: 'Polygon' != 'Unk…
import fiona
import fiona.crs
def convert(f_in, f_out):
with fiona.open(f_in) as source:
with fiona.open(
f_out,
'w',
driver='GeoJSON',
crs = fiona.crs.from_epsg(4326),
@jwass
jwass / convert.py
Created August 10, 2013 21:13
Simple script used to convert some shapefiles to GeoJSON, leaving out a few undesired properties. Requires shapely 1.2.18.
import functools
import fiona
import geojson
import pyproj
import shapely.geometry
import shapely.ops
omit = ['SHAPE_AREA', 'SHAPE_LEN']