0

I've created MbTiles with gdal_translate in the OSGeo4W Shell.

The workflow was at follows:

  1. convert jp2 files to geotiff with gdal_translate
  2. create a Virtual Raster for all raster files (about 1000) with gdalbuildvrt
  3. create overviews for vrt with gdaladdo
  4. create mbtiles with gdal_translate
  5. create overviews for mbtiles with gdaladdo

After this process I've loaded the mbtiles to QGIS 3.2. The MbTiles was only shown at scale leves between 1:200 and 1:5000. If I wanted to have a lager scale, because I've wanted to see the whole project area, the MbTiles disappeared.

Here is the code I've used in detail:

C:
cd C:/.... #repository
FOR %i IN (*.jp2) do "gdal_translate" -a_srs "EPSG:31255" -of GTIFF -co "TFW=yes" -r bilinear -tr 0.4 0.4 "%i" "%i.tif"

gdalbuildvrt -a_srs "EPSG:31255" -r bilinear -tr 0.4 0.4 -vrtnodata "0 0 0" -input_file_list "C:\...\my_list.txt" vrt_test.vrt

gdaladdo -r bilinear vrt_test.vrt 2,4,8,16

gdal_translate -of MBTiles -co "TILE_FORMAT=JPEG" -co "QUALITY=85" -co "RESAMPLING=BILINEAR" "C:\...\vrt_test.vrt" "mbtiles_test.mbtiles"

gdaladdo -r bilinear --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config BIGTIFF_OVERVIEW -ro mbtiles_test.mbtiles 2,4,8,16

Has anybody an idea what's wrong?

5
  • By "large scale", do you mean a big scale denominator, like 1:10000 or 1:20000?
    – user30184
    Commented Oct 4, 2018 at 10:01
  • Yes, exactily. When I zoom to a scale, greater than 1:5000 the mbtiles disappers.
    – Helga F.
    Commented Oct 4, 2018 at 10:25
  • GIS people tend to call a ratio with a big denominator as a small scale because mathematically it is just so. Just remember "big number - small scale".
    – user30184
    Commented Oct 4, 2018 at 10:36
  • Okay, thanks for your advice. I'm new in GIS business, so excude my expressions.
    – Helga F.
    Commented Oct 4, 2018 at 10:56
  • No need to apologize, "small scale" just isn't intuitive. It is always good to check if people mean zoomed-in or zoomed-out situation when they talk about small or large scale.
    – user30184
    Commented Oct 4, 2018 at 11:18

1 Answer 1

1

Principal reason for the problem is that your gdaladdo commands are wrong and you have now only one overview level "2". Other resolututions in your comma separated list 2,4,8,16 were never created.

gdal_translate -a_srs "EPSG:31255" -of GTIFF -co "TFW=yes" -r bilinear -tr 0.4 0.4 "%i" "%i.tif

I believe that your first command is not necessary at all. The only possible advantage in running that is that a virtual raster of GeoTIFF files might be faster than a virtual raster of JPEG 2000 files. The speedup is unlikely with this exact command because it writes striped, not tiled GeoTIFFs. I recommend to try your next command directly with a list of JPEG 2000 files.

gdalbuildvrt -a_srs "EPSG:31255" -r bilinear -tr 0.4 0.4 -vrtnodata "0 0 0" -input_file_list "C:\...\my_list.txt" vrt_test.vrt

gdaladdo -r bilinear vrt_test.vrt 2,4,8,16

This command will create only one overview with level 2 and I think that overviews are not even needed in this place. Why it creates only one overview is that the list of overview levels is not comma separated. Spaces must be used instead https://www.gdal.org/gdaladdo.html.

gdal_translate -of MBTiles -co "TILE_FORMAT=JPEG" -co "QUALITY=85" -co "RESAMPLING=BILINEAR" "C:\...\vrt_test.vrt" "mbtiles_test.mbtiles"

This is OK.

gdaladdo -r bilinear --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config BIGTIFF_OVERVIEW -ro mbtiles_test.mbtiles 2,4,8,16

This should work if you just change the list of levels into 2 4 8 16. If you have GDAL version 2.3 or higher you do not even define the levels because gdaladdo creates reasonable overview levels automatically.

Do you have any special reason for creating external overviews as BigTIFF? By leaving out -ro you would get internal overviews added as new zoom levels into your MBTiles database which feels more natural. I am not sure if all your config options make sense with internal overviews but they should not make harm either.

1
  • Thanks for your input. After try and error the solution of the problem was gdaladdo. I add more levels and afterwards the whole project area was visible at small scale. (1:300000)
    – Helga F.
    Commented Oct 9, 2018 at 11:38

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.