Skip to content

Instantly share code, notes, and snippets.

View mvexel's full-sized avatar

Martijn van Exel mvexel

View GitHub Profile
@mvexel
mvexel / generate_time_slices.sh
Created October 17, 2017 21:54
Generate time slices from a full history PBF file (HACK ALERT)
#!/bin/sh
osmium time-filter utah.osh.pbf 2007-01-01T00:00:00Z -o utah-20070101.osm.pbf
osmium time-filter utah.osh.pbf 2007-02-01T00:00:00Z -o utah-20070201.osm.pbf
osmium time-filter utah.osh.pbf 2007-03-01T00:00:00Z -o utah-20070301.osm.pbf
osmium time-filter utah.osh.pbf 2007-04-01T00:00:00Z -o utah-20070401.osm.pbf
osmium time-filter utah.osh.pbf 2007-05-01T00:00:00Z -o utah-20070501.osm.pbf
osmium time-filter utah.osh.pbf 2007-06-01T00:00:00Z -o utah-20070601.osm.pbf
osmium time-filter utah.osh.pbf 2007-07-01T00:00:00Z -o utah-20070701.osm.pbf
osmium time-filter utah.osh.pbf 2007-08-01T00:00:00Z -o utah-20070801.osm.pbf
@mvexel
mvexel / count_pbfs.py
Created October 17, 2017 21:53
Count objects in a series of OSM PBF files
"""
Count objects in a series of OSM files.
Build a CSV file with object counts for a series of PBF
time slices generated from a history file
"""
from __future__ import print_function
import osmium as o
from os.path import exists
import csv
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
mkdir -p ~/tmp/tiger
cd ~/tmp/tiger
wget http://www2.census.gov/geo/tiger/GENZ2016/shp/cb_2016_us_county_500k.zip
unzip cb_2016_us_county_500k.zip
wget http://www2.census.gov/geo/tiger/GENZ2016/shp/cb_2016_us_state_500k.zip
unzip cb_2016_us_state_500k.zip
createdb tiger
psql -d tiger -c 'create extension postgis'
shp2pgsql -D -I cb_2016_us_state_500k.shp > cb_2016_us_state_500k.sql
shp2pgsql -D -I cb_2016_us_county_500k.shp > cb_2016_us_county_500k.sql
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mvexel
mvexel / 20160208-local-wg.md
Last active August 25, 2017 19:04
20160208-local-wg.md

US Local Working Group

Call on 2/8/2016 8pm ET

Clifford, Martijn, Charlotte

Previously...

Notes

12:26 $ rake test:db
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's 'rails' settings.
Run options: --seed 7757
# Running:
.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
@mvexel
mvexel / select_exits.md
Created February 10, 2017 17:00
select motorway exit nodes SQL

I use this series of queries to get all nodes that should represent motorway_junction nodes:

-- create temp table to store all motorway nodes
create table motorway_nodes as (select (st_dump(st_points(linestring))).geom geom, id from ways where tags->'highway' = 'motorway');
-- create temp table to store all motorway_link start nodes
create table motorway_link_start_nodes as (select st_pointn(linestring, 1) geom, id from ways where tags->'highway' = 'motorway_link');
-- create temp table with the intersection between these two
create table offramp_starts as (select l.id lid, m.id mid, l.geom from motorway_nodes m, motorway_link_start_nodes l where st_equals(m.geom, l.geom));
-- select the OSM nodes at these locations
@mvexel
mvexel / devos-call-script.md
Last active January 28, 2017 21:00
devos-call-script.md

Mr [SENATOR],

My name is [NAME] and I live in [CITY], [STATE]. I am calling to express my grave concerns about Ms DeVos, the current candidate for Secretary of Education. Her confirmation hearings showed to me that she lacks basic knowledge about our public education system. A system that Ms DeVos seems intent on dismantling in favor of privately run schools. There is no precedent for such a change working to benefit the quality of education at scale. Our education system is already fragile, and many measures could be taken to improve it, but navigating down this uncharted and ill-informed path that will be impossible to backtrack from is not one that we should take. Therefore, Ms DeVos is not a suitable person to lead education policy, and I ask of you in the strongest possible terms to not support her candidacy.

Thank you for listening.

@mvexel
mvexel / restrictions-in-toronto.csv
Last active December 21, 2016 01:48
restrictions-in-toronto.csv
@id restriction restriction:conditional
14986 no_left_turn
15054 no_right_turn
15056 no_right_turn
56407 no_right_turn
69208 no_left_turn @ (Mo-Fr 15:30-18:30)
69210 no_left_turn
69211 no_left_turn
69212 no_left_turn
69213 no_left_turn