Creating MBTiles from GeoTiff from USGS Data Sets
·2 mins
Creating MBTiles from GeoTiff from USGS Data Sets #
Expand all of the zip files #
unzip \*.zip
Copy all of the tiff files to a single directory #
mkdir for_merge && cp vol001/* for_merge && cp vol002/* for_merge && cd for_merge
Convert all resulting tiff files to EPSG:3857 #
for i in *.tif; do gdalwarp -t_srs EPSG:3857 -r near "$i" "$i"; done
Merge all the tiffs into a single file #
gdal_merge.py -init 255 -o merged.tif $(for i in *.tif; do echo "$i"; done)
Translate the tiff file into mbtiles #
# gdal_translate -of mbtiles merged.tif pensacola-hires-ortho.mbtiles
gdal_translate -of mbtiles -co "TILE_FORMAT=JPEG" -co "QUALITY=90" -co "ZOOM_LEVEL_STRATEGY=UPPER" merged.tif pensacola-hires-ortho.mbtiles
Build overview images for mbtiles file #
gdaladdo -r nearest pensacola-hires-ortho.mbtiles 2 4 8 16 32
To Add These MBTiles to Tileserver-gl #
Move mbtiles to the server data directory #
mv pensacola-hires-ortho.mbtiles ~/Resilio\ Sync/Code_Projects/Docker/mapserver/data-gl
The method below contains all zoom levels, but takes FOREVER
Install gdal2mbtiles
for Easier Translation #
gdalinfo --version # to get gdal version
pip3 install --global-option=build_ext --global-option=--gdal-config=/usr/bin/gdal-config --global-option=--include-dirs=/usr/include/gdal/ GDAL==2.2.3 # whatever gdal version we got from previous command
sudo apt-get install libvips libvips-dev
sudo apt-get install libtiff5 optipng pngquant
git clone https://github.com/ecometrica/gdal2mbtiles.git
cd gdal2mbtiles
python setup.py install
gdal2mbtiles --name Pensacola --layer-type baselayer --version "1.0.0" --format jpg --min-resolution 1 --max-resolution 19 merged.tif pensacola-hires-ortho-3.mbtiles