Skip to content

Instantly share code, notes, and snippets.

@DavidArsene
Last active September 1, 2025 13:48
Show Gist options
  • Select an option

  • Save DavidArsene/8485953665e5cd5691171d605e480557 to your computer and use it in GitHub Desktop.

Select an option

Save DavidArsene/8485953665e5cd5691171d605e480557 to your computer and use it in GitHub Desktop.
Download image tiles from Wplace. Uses wget and imagemagick.
#!/usr/bin/env bash
set -euo pipefail
# How to use:
# Look at network requests for s0/tiles, then first number is latitude, second is longitude.
[[ $# -ne 5 ]] && { echo "Usage: $0 <dir> <lat_start> <lat_end> <lon_start> <lon_end>"; exit 1; }
dir="$1"
lat_start="$2"
lat_end="$3"
lon_start="$4"
lon_end="$5"
lat_num=$((lat_end - lat_start + 1))
lon_num=$((lon_end - lon_start + 1))
mkdir -p "$dir/out"
for lat in $(seq $lat_start $lat_end); do
for lon in $(seq $lon_start $lon_end); do
file="$dir/$lon-$lat.png"
# Naming files lon-lat aligns bash's * globbing with the order used by imagemagick
if [ -f "$file" ]; then
if [[ ! -s "$file" ]]; then
echo "$file is empty, re-downloading."
else
echo "$file already downloaded."
continue
fi
fi
wget "https://backend.wplace.live/files/s0/tiles/$lat/$lon.png" -O "$file"
[[ $? -ne 0 ]] && { echo "Rate limit at latitude $lat and longitude $lon"; exit 1; }
done
done
echo "Creating ${lat_num}x${lon_num} montage..."
files=$(eval echo "$dir/{$lon_start..$lon_end}-{$lat_start..$lat_end}.png")
magick montage -background none -alpha on -geometry +0+0 -tile ${lat_num}x${lon_num} $files "$dir/out/$lat_start-$lat_end-$lon_start-$lon_end.png"
@TomW1605
Copy link

hi, this looks good but how do you get the long and lat?

@DavidArsene
Copy link
Author

DavidArsene commented Aug 18, 2025

@TomW1605 look at network requests for "https :// backend.wplace.live/files/s0/tiles/$lat/$lon.png" while dragging the map zoomed in around that area

@TomW1605
Copy link

thanks

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