Skip to content

Instantly share code, notes, and snippets.

@daniel-j-h
Created August 9, 2016 10:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-j-h/6a1dbe506b9bb443bd21c2d7d466302e to your computer and use it in GitHub Desktop.
Save daniel-j-h/6a1dbe506b9bb443bd21c2d7d466302e to your computer and use it in GitHub Desktop.
1/ go to geojson.io draw bounding box, save as bbox.geojson 2/ cut.sh big.pbf bbox.geojson small.pbf
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ $# -ne 3 ]; then
echo "Usage: cut.sh planet.pbf bbox.geojson outfile"
exit 1
fi
readonly bbox=$(jq --raw-output '.features[0].geometry.coordinates[0] | "top=" + ( .[1][1] | tostring) + " left=" + ( .[0][0] | tostring ) + " bottom=" + ( .[0][1] | tostring ) + " right=" + ( .[2][0] | tostring )' "${2}")
osmosis \
--read-pbf "${1}" \
--bounding-box ${bbox} \
--write-pbf "${3}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment