Files
resolved/scripts/fetch-earth.sh
T
2026-10-14 20:12:49 -04:00

54 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
# Downloads NASA's Blue Marble Next Generation monthly Earth images and resizes
# them for the renderer.
#
# Source: Blue Marble: Next Generation (2004), base map without topography or
# bathymetry, 21600 x 10800 (500 m per pixel), one image per month, from
# https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/.
# Produced by Reto Stöckli, NASA Earth Observatory; NASA asks that users credit
# "NASA Earth Observatory".
#
# The originals go to data/earth/source/ and are checked by sha256. Each is
# resized to 16384 x 8192 (660 m per pixel), the largest texture lavapipe takes,
# into data/earth/bmng-2004-MM.jpg. Resizing uses ImageMagick (`magick`).
# Both directories are gitignored.
set -eu
base='https://assets.science.nasa.gov/content/dam/science/esd/eo/images/bmng/bmng-base'
root="$(cd "$(dirname "$0")/.." && pwd)/data/earth"
mkdir -p "$root/source"
# month number, folder name, sha256 of the original
while read -r n month sum; do
original="$root/source/world.2004$n.3x21600x10800.jpg"
if [ ! -f "$original" ]; then
echo "fetching $month"
curl -fsSL "$base/$month/world.2004$n.3x21600x10800.jpg" -o "$original.part"
mv "$original.part" "$original"
fi
echo "$sum $original" | sha256sum -c --quiet -
resized="$root/bmng-2004-$n.jpg"
if [ ! -f "$resized" ]; then
echo "resizing $month"
# Resample in linear light, then back to sRGB, so averaging is of reflectance.
magick "$original" -colorspace RGB -filter Lanczos -resize 16384x8192! \
-colorspace sRGB -quality 95 "$resized"
fi
done <<'EOF'
01 january c2f2c80a352518cfea23d462dad6f6e778375ddd74bbec5786bcfc85cc49c61d
02 february 8800081f38b53bfa1e3f0c2fa17be694b7646942fe5add009ea0dcd64c03e70b
03 march af37f61a9715c59dc86763df19f588a20c9d92b3d0a8034a0b00acd6b97ccb7d
04 april 3bd13f173555eb24451c45d3a83ca177baca02e9a8bdd9fa3e4989f7b496ce6b
05 may 0de40c868680ab9e86fef42406d76386b243b32444ff50edfd406b296638c206
06 june 282608580a290723655bfbe917e69ea2f93f4da068dfa96ff4a152b1c6ec36be
07 july dea8b4dc8a4f93f5f8bce0c8c85a508a178e7901e9ed8e6bf86e6ce7ef6d61e2
08 august 926be7253be90a1fd57071a33afbfe7a712a2dfe0d5b5b4602bc5dfbcfdc2c89
09 september 7cf788e13a3a7b4a926b524f8f71d635c56a18c48ba0bfe35695b05a305db3f3
10 october bf568ceca2ad55e9c8dd7bcedfd0e419201d03bb560206a7bfa2cc57c1e04c64
11 november 1959bbe72897d3e9526c440dae3ec04cfdbdc4080c8ff0b14632925ae31167b1
12 december b0ffc9d12205689aeaec66116bbae2c4c263fcd98a0cbadba8d5488567b53278
EOF
echo "Earth images in $root"