Skip to content

Instantly share code, notes, and snippets.

View urschrei's full-sized avatar

Stephan Hügel urschrei

View GitHub Profile
@urschrei
urschrei / Plaques_Geopandas.ipynb
Last active August 29, 2015 14:04
GLA Electoral wards with blue plaque counts from openplaques
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@urschrei
urschrei / keybase.md
Created September 23, 2014 16:37
keybase.md

Keybase proof

I hereby claim:

  • I am urschrei on github.
  • I am shugel (https://keybase.io/shugel) on keybase.
  • I have a public key whose fingerprint is 981F 92FE DC9A 0F9B 010E 43D2 C6CA 03B7 BB85 14EB

To claim this, I am signing this object:

@urschrei
urschrei / hexgrid.py
Last active May 4, 2022 11:57
Python Hexgrid
import math
def calculate_polygons(startx, starty, endx, endy, radius):
"""
Calculate a grid of hexagon coordinates of the given radius
given lower-left and upper-right coordinates
Returns a list of lists containing 6 tuples of x, y point coordinates
These can be used to construct valid regular hexagonal polygons
@urschrei
urschrei / contour.ipynb
Last active March 14, 2021 16:11
Map interpolated values using a contour plot, and a scatter plot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
# In[147]:
from Circles.circles import circle
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from shapely.geometry import Polygon, MultiPolygon, Point, LineString
@urschrei
urschrei / plot_groups_over_time.py
Last active August 29, 2015 14:13
Loop through a grouped, time-series-indexed Pandas DataFrame, plotting category counts per year
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# this data won't work (it's only for one year), it's only illustrative
df = pd.DataFrame({
'Age': {0: 32, 1: 38, 2: 45, 3: 39, 4: 44},
'County': {0: 'Bexar', 1: 'Tarrant', 2: 'Harris', 3: 'Nueces', 4: 'Kerr'},
'Date Executed': {
0: '10/28/2014',
@urschrei
urschrei / output_geojson.py
Last active August 29, 2015 14:16
Output a GeoJSON FeatureCollection to file from dict point data input
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
output geojson.py
Created by Stephan Hügel on 2015-02-26
I can *never* remember how to efficiently do this, so I'm making a gist.
This should be easily adaptable to use with LineStrings, Polygons etc by
altering the 'geometry' dict accordingly
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="verbose"
export GIT_PS1_SHOWDIRTYSTATE
export GIT_PS1_SHOWSTASHSTATE
export GIT_PS1_SHOWUNTRACKEDFILES
export GIT_PS1_SHOWUPSTREAM
PS1='\[\e[32m\]\u\[\e[00m\]:\[\e[34m\]\w\[\e[00m\]\[\e[35m\]$(__git_ps1 " (%s)")\[\e[00m\] $ '
export PS1
@urschrei
urschrei / moved.md
Last active August 29, 2015 14:26
Comparing Mapzen's OSRM and Valhalla routing engine results for bicycle journeys in London
@urschrei
urschrei / playground.rs
Last active February 2, 2016 09:59 — forked from anonymous/playground.rs
Threaded send/receive using channels in Rust
use std::thread;
use std::sync::mpsc::{ channel, Sender };
enum Wrapped {
A(f64),
B(f64),
}
fn produce_a(sender: Sender<Wrapped>) {
for i in 0 .. 5 {