Skip to content

Instantly share code, notes, and snippets.

Avatar

Martijn van Exel mvexel

View GitHub Profile
View pip-install-osmium.txt
$ pip install osmium
Collecting osmium
Using cached https://files.pythonhosted.org/packages/f1/74/4b06a023c19006133309bfbc5460bede50f451089c01ca7fa9caa1d06bf4/osmium-2.14.3.tar.gz
Building wheels for collected packages: osmium
Running setup.py 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/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\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
mvexel / get_users_in_area.py
Created Apr 6, 2018
Get unique OSM contributors for a named area
View get_users_in_area.py
#!/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)
View StringSearch.java
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
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
COPY (
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
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
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
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.
@mvexel
mvexel / states.txt
Created Oct 18, 2017
US state boundaries in geojson format
View states.txt
This file has been truncated, but you can view the full file.