Skip to content

Instantly share code, notes, and snippets.

@philippgeisler
Created July 11, 2014 13:48
Show Gist options
  • Save philippgeisler/9871032bd7529cd3c0ab to your computer and use it in GitHub Desktop.
Save philippgeisler/9871032bd7529cd3c0ab to your computer and use it in GitHub Desktop.
Shell script grabbing bounding box coordinates for an array of cities
#!/usr/bin/zsh
url='http://open.mapquestapi.com/nominatim/v1/search.php'
# url='http://nominatim.openstreetmap.org/search'
if [ -e locations ]
then
rm locations
fi
for c in Berlin Dortmund Frankfurt Hamburg München
do
wget -O "bbox-$c.json" "$url?city=$c&countrycodes=de&limit=1&format=json"
jq -c '.[].display_name,(.[].boundingbox|.[])' "bbox-$c.json" | tr '\n' ' ' | sed 's/"//g' | sed 's/,.*[a-z]\ /\ /' >> locations
echo >> locations
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment