source: https://jean.ribes.ovh/posts/export-satellite-map-to-mbtiles/
# Export satellite map to MBtiles

Several services offer so-called XYZ raster maps, that you can add to QGIS.

Use the following script to download an online map to a folder.

Beware of the zoom level, because increasing level will download exponentially more tiles than the previous on.

Each zoom level is comprised of `2^(2×n)` tiles !

Also, check the terms and conditions of the service, they don't really expect people to suddenly download **1048576 tiles** (all level 10).

```bash {.kg-width-wide}
#!/bin/bash
zoom=$1
cote=$(( 2**zoom ))
echo "$cote -> $(( cote**2 ))"
set -x
mkdir -p "$zoom"
for x in $(seq 0 "$(( cote - 1 ))"); do
        mkdir -p "$zoom/$x"
        for y in $(seq 0 "$(( cote - 1 ))"); do
                wget --no-clobber -O "$zoom/$x/$y.format" "$URL/$zoom/$x/$y"
                #mogrify -format jpg "$zoom/$x/$y.format"
        done
done

```

Edit the script (replace $URL and format), you can use the mogrify command (part of imagemagick) to convert images to many formats such as png, jpg...

Then run it with `./script.sh 1` for zoom level 1 and so on.

You end up with several folders full of tiles that can the be converted to MBtiles with [mb-util](https://github.com/mapbox/mbutil):

```bash
./mb-util ./your-folder output.mbtiles --image_format=jpg

```

`mb-util` only support png, jpg, webp or pbf (PBF is for vector tiles)

You can the add the `.mbtiles` file as a QGIS layer, which will load the tiles depending on your current zoom.

If you don't want to suddenly download lots of files, you can also set up a caching proxy such as [agorf/tileproxy](https://github.com/agorf/tileproxy)


© 2026 Jean Ribes