Created
September 3, 2021 05:13
-
-
Save mdav43/e81298a5fb6c0c53614df41953715648 to your computer and use it in GitHub Desktop.
Merge overland ios app geojson files into one file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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