Skip to content

Instantly share code, notes, and snippets.

@mdav43
Created September 3, 2021 05:13
Show Gist options
  • Save mdav43/e81298a5fb6c0c53614df41953715648 to your computer and use it in GitHub Desktop.
Save mdav43/e81298a5fb6c0c53614df41953715648 to your computer and use it in GitHub Desktop.
Merge overland ios app geojson files into one file.
#!/bin/bash
# A script to combine geojson files produced by Overland iOS app into one file.
if ! command -v jq &> /dev/null
then
echo "jq command could not be found. Ensure it is installed and runnable from current context"
exit
fi
read -p "Are you sure you want to combine geojson files. This will only work with overland filetypes? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# Combine the raw geojson files from overland-ios app that have been recorded
jq 'reduce inputs.locations as $s (.; .locations += $s)' *.geojson > merged.geojson
# Extract all the locations and wrap in the correct Parent element for GeoJSON format. I'm ignoring all the "current" tags in the files as they aren't really necessary
jq '.locations | {"type": "FeatureCollection", "features": [.[]] }' merged.geojson > merged_and_wrapped.geojson
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment