Skip to content

Instantly share code, notes, and snippets.

@aoles
Created October 25, 2018 10:32
Show Gist options
  • Save aoles/4167a15b054f609b49cd6fb92179e37a to your computer and use it in GitHub Desktop.
Save aoles/4167a15b054f609b49cd6fb92179e37a to your computer and use it in GitHub Desktop.
Sample script for creating geographic extracts of OSM data
#!/bin/bash
URL=https://download.geofabrik.de/europe/germany/baden-wuerttemberg/karlsruhe-regbez-latest.osm.pbf
RELATION_ID=62691
RELATION_NAME=mannheim
###
echo "Downloading $URL"
SOURCE=$(basename "$URL")
curl $URL -o $SOURCE
echo "Getting boundary"
BOUNDARY=$RELATION_NAME-boundary.osm
osmium getid -r $SOURCE r$RELATION_ID -o $BOUNDARY
echo "Extracting region"
OUTPUT=$RELATION_NAME.osm.gz
osmium extract -p $BOUNDARY $SOURCE -o $OUTPUT --overwrite
rm $BOUNDARY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment