Continue from this link, for my situation, the only way to generate .tif to .mbtiles is gdal_translate in QGIS.

This is the .json after using gdal_translate

Setting: GDAL > Raster conversion > translate(convert format)

  "tiles": [
  "name": "something8",
  "format": "png",
  "basename": "something8.mbtiles",
  "id": "something8",
  "type": "overlay",
  "description": "something8",
  "version": "1.1",
  "bounds": [
  "minzoom": 21,
  "maxzoom": 21,
  "center": [
  "tilejson": "2.0.0"

And this is the what I need:

  "tiles": [
  "name": "something",
  "format": "png",
  "basename": "something.mbtiles",
  "id": "something",
  "type": "overlay",
  "description": "something",
  "version": "1.1",
  "minzoom": 8,
  "maxzoom": 25,
  "bounds": [
  "center": [
  "tilejson": "2.0.0"

As you can see the above .json minzoom and maxzoom is fixed at 21, and the below are 8-25. How to set the zoom level from 14-20?

Any idea?

2 Answers 2


By the documentation https://gdal.org/drivers/raster/mbtiles.html the driver allows only small adjustment to the base zoom level

ZOOM_LEVEL_STRATEGY=AUTO/LOWER/UPPER. Strategy to determine zoom level. LOWER will select the zoom level immediately below the theoretical computed non-integral zoom level, leading to subsampling. On the contrary, UPPER will select the immediately above zoom level, leading to oversampling. Defaults to AUTO which selects the closest zoom level.

Oversampling more that to UPPER is unreasonable, it would just split pixels and explode the disk space.

How to add lower zoom levels is documented in https://gdal.org/drivers/raster/mbtiles.html#overviews-raster

Overviews (raster)

gdaladdo / BuildOverviews() can be used to compute overviews. Only power-of-two overview factors (2,4,8,16,…) are supported.

If more overview levels are specified than available, the extra ones are silently ignored.

So, for adding zoom levels 14-20 use gdaladdo and see if it is willing to create all the zoom levels that you ask.

gdaladdo my_mbtiles.mbtiles 2 4 8 16 32 64 128

gdal_translate allows setting the target raster resolution in georeferenced units per pixel using the -tr option. That can effectively set maxzoom. For example, if the georeferenced units are meters and the desired maximum resolution is 1.0 meters per pixel, one can use e.g.:

gdal_translate -tr 1.0 1.0 -projwin 480000 6600000 481000 6599000 -projwin_srs EPSG:3857 -co TILE_FORMAT=PNG -co TYPE=baselayer -of MBTILES frmt_wms_openstreetmap_tms.xml my_tiles.mbtiles

to download a piece of OpenStreetMap to mbtiles. The source dataset XML configuration file is frmt_wms_openstreetmap_tms.xml:

    <Service name="TMS">
    <UserAgent>Please add a specific user agent text, to avoid the default one being used, and potentially blocked by OSM servers in case a too big usage of it would be seen</UserAgent>
    <Cache />

When reading TMS (XYZ tile) maps, the <TileLevel>19</TileLevel> setting also sets the maximum allowed zoom level directly for the source dataset and can be used instead of the -tr option. See https://gdal.org/drivers/raster/wms.html#tms for the relevant documentation.

As @user30184 answered, to set the minzoom limit, one needs to add lower zoom levels (overview images) to the produced mbtiles file using gdaladdo. Assuming your maxzoom is 20, add six lower zoom levels (14-19) using:

gdaladdo my_mbtiles.mbtiles 2 4 8 16 32 64

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.