Skip to content

Instantly share code, notes, and snippets.

@NBrown140
Last active June 21, 2023 15:24
Show Gist options
  • Save NBrown140/66841ca244dc85a8b0d6747cd2d16899 to your computer and use it in GitHub Desktop.
Save NBrown140/66841ca244dc85a8b0d6747cd2d16899 to your computer and use it in GitHub Desktop.
Download full AW3D30 v3.2 dataset
#!/bin/bash
# Script to download all the tiles of the AW3D30 v3.2 dataset
download () {
# I've noticed that non-existing tiles return a 302 response code.
# I assume all the tiles with data have a url that returns 200 response code.
local url=https://www.eorc.jaxa.jp/ALOS/aw3d30/data/release_v2012/$1
echo Cheking $url
local respcode=$(curl -o /dev/null --silent -Iw '%{http_code}' $url)
echo Response code: $respcode
if [ $respcode -eq 200 ]; then
echo Downloading...
curl -OL --silent $url
fi
}
# Northern Hemisphere
for lat in {000..080..5}; do
# North-East quadrant
for lon in {000..175..5}; do
file="N${lat}E${lon}_N$(printf '%03d' $((10#$lat + 05)))E$(printf '%03d' $((10#$lon + 05))).zip"
download $file
done
# North-West quadrant
for lon in {005..180..5}; do
if [ $lon -eq 005 ]; then
secondLonHem="E"
else
secondLonHem="W"
fi
file="N${lat}W${lon}_N$(printf '%03d' $((10#$lat + 05)))${secondLonHem}$(printf '%03d' $((10#$lon - 05))).zip"
download $file
done
done
# Sourthern Hemisphere
for lat in {005..085..5}; do
# South-East quadrant
for lon in {000..175..5}; do
if [ $lat -eq 005 ]; then
secondLatHem="N"
else
secondLatHem="S"
fi
file="S${lat}E${lon}_${secondLatHem}$(printf '%03d' $((10#$lat - 05)))E$(printf '%03d' $((10#$lon + 05))).zip"
download $file
done
# South-West quadrant
for lon in {005..180..5}; do
if [ $lat -eq 005 ]; then
secondLatHem="N"
else
secondLatHem="S"
fi
if [ $lon -eq 005 ]; then
secondLonHem="E"
else
secondLonHem="W"
fi
file="S${lat}W${lon}_${secondLatHem}$(printf '%03d' $((10#$lat - 05)))${secondLonHem}$(printf '%03d' $((10#$lon - 05))).zip"
download $file
done
done
@dwightgunning
Copy link

Thanks for the share!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment