Last active
June 21, 2023 15:24
-
-
Save NBrown140/66841ca244dc85a8b0d6747cd2d16899 to your computer and use it in GitHub Desktop.
Download full AW3D30 v3.2 dataset
This file contains hidden or 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 | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference JAXA website: https://www.eorc.jaxa.jp/ALOS/en/dataset/aw3d30/aw3d30_e.htm
Used @aldoridhoni's gist for inspiration: https://gist.github.com/aldoridhoni/2a9740721f6d9bb5ef958590064a2acc
Compared to @acalcutt's https://github.com/acalcutt/jaxa_AW3D30_to_MBTiles/blob/main/file_list_zip.txt and got the same list of files, which gives me confidence that this does indeed download all the tiles.