Skip to content

Instantly share code, notes, and snippets.


Martijn van Exel mvexel

View GitHub Profile
mvexel / gist:0670afeab32bbff7f319eef0f0b77c42
Last active Sep 18, 2018
View gist:0670afeab32bbff7f319eef0f0b77c42
$ brew install python
Warning: Building python from source:
The bottle needs the Apple Command Line Tools to be installed.
You can install them, if desired, with:
xcode-select --install
==> Downloading
Already downloaded: /Users/martijnv/Library/Caches/Homebrew/downloads/f87e3a4f88925ead242c820be2fef7aa64d70507a5c4f8e544e666263a881f41--Python-3.7.0.tar.xz
==> ./configure --prefix=/usr/local/Cellar/python/3.7.0 --enable-ipv6 --dataroot
==> make
View pip-install-osmium.txt
$ pip install osmium
Collecting osmium
Using cached
Building wheels for collected packages: osmium
Running bdist_wheel for osmium ... error
Complete output from command /usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/3g/z8ymv2x55sn1xfjdyvd3bsywdzx3tl/T/pip-install-dkeu62ne/osmium/';f=getattr(tokenize, 'open', open)(__file__);'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/3g/z8ymv2x55sn1xfjdyvd3bsywdzx3tl/T/pip-wheel-965bzp95 --python-tag cp37:
libosmium found in 'libosmium-2.14.2'.
protozero found in 'protozero-1.6.3'.
running bdist_wheel
running build
View osc-needed.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
mvexel /
Created Apr 6, 2018
Get unique OSM contributors for a named area
#!/usr/bin/env python3
import overpass
area_name = "Kanab"
query = """area[name="{}"]->.slc;(node(area.slc);<;);""".format(area_name)
users = {"ids": [], "usernames": []}
api = overpass.API(debug=False)
public class StringSearch {
public static void main(String[] args) {
// Initialize a new String
String myString = "Thanksgiving Day";
System.out.println("Our string is: " + myString);
// Now, get the 3rd letter in this string.
// Remember that indexes are zero based,
// so the third character has index 2, not 3.
mvexel / query-states-geojson.sql
Created Oct 18, 2017
query on a TIGER states table (Imported from Census SHAPE using shp2pgsql) to generate GeoJSON for each that osmium will understand.
View query-states-geojson.sql
SELECT name, jsonb_build_object(
'type', 'Feature',
'id', gid,
'geometry', ST_AsGeoJSON(geom)::jsonb,
'properties', to_jsonb(row) - 'gid' - 'geom')
FROM (SELECT * FROM cb_2016_us_state_500k) row)
TO '/Users/martijnv/osm/planet/states.tsv';
mvexel / gist:5273c69d6b58587b5004e0a53ae34e75
Created Oct 18, 2017
osmium command to process N-America history into states using config file (see other gist)
View gist:5273c69d6b58587b5004e0a53ae34e75
osmium extract -H --overwrite -c osmium-config.json north-america.osh.pbf
mvexel / osmium-config.json
Created Oct 18, 2017
osmium config file to extract state history PBFs
View osmium-config.json
"extracts": [
"description": "Full history PBF of Alabama",
"output": "Alabama.osh.pbf",
"output_format": "pbf",
"polygon": {
"file_name": "Alabama.geojson",
"file_type": "geojson"
mvexel / states.tsv
Created Oct 18, 2017
GeoJSON of all states (wrapped as Features this time with all TIGER attributes as properties)
View states.tsv
We can't make this file beautiful and searchable because it's too large.