Skip to content

Instantly share code, notes, and snippets.

@ckhung
Last active August 29, 2015 14:25
Show Gist options
  • Save ckhung/486ffca6f8c966c2daac to your computer and use it in GitHub Desktop.
Save ckhung/486ffca6f8c966c2daac to your computer and use it in GitHub Desktop.
convert GraphHopper exported gpx to geojson suitable for importing into umap
#!/bin/bash
# usage: gh2umap.sh directions.gpx > directions.geojson
# see http://newtoypia.blogspot.tw/2015/07/fs-biking.html
TMPDIR=/tmp/gh2umap-$$
mkdir $TMPDIR
ogr2ogr -f geojson $TMPDIR/tr.geojson $1 tracks
jq '.features' $TMPDIR/tr.geojson > $TMPDIR/tracks.geojson
ogr2ogr -f geojson $TMPDIR/rp.geojson $1 route_points
opencc < $TMPDIR/rp.geojson | jq '.features | map(.properties+={_storage_options: {"iconClass": "Ball"}} | .properties.name=.properties.desc )' > $TMPDIR/route_points.geojson
jq -s '.[0] + .[1]' $TMPDIR/tracks.geojson $TMPDIR/route_points.geojson
rm -rf $TMPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment