Generating Cloud Optimized GeoTIFFs and Raster Tiles with GDAL
TLDR: gdalbuildvrt, gdal_translate, gdal_warp and gdaladdo
The following outlines the basic steps for generating Cloud Optimized GeoTIFFs and raster tiles from one or more raw TIFF files.
Create the Mosaic
Separate the bands and add an alpha band that gdal can use.
|
Update 3/22/2022 - If you run into the error “gdalbuildvrt does not support heterogeneous projection” you can warp all the source TIFF files into the desired projection, then run the command above, using the warped vrt files as the source files. See this Stack Exchange post
|
|
Create the Desktop Cloud Optimized GeoTIFF
Force the NAD83 projection using either EPSG:6551 (NAD83 2011) or 3735.
Update 2/10/2022 - For Desktop GIS usage, higher clarity may be found by using the NEAREST resampling method at the expense of pixelation. When using this method, set the resampling to bilinear
or cubic
in the GIS software when adding the COG.
|
Create a Mosaic in WebMercator from the Original Mosaic
Use the ITRF00 transformation suitable for both 6551 and 3735.
|
Create the COG in WebMercator for use in a COG Server
If you want to use the COG in ArcGIS Server then use JPEG compression.
Using the default resampling works fine as does AVERAGE, BILINEAR and CUBIC (default).
Update 2/10/2022 - Using AVERAGE may provide more clarity for the overviews.
|
Check your COG with the coggeotiff
cli tool
|
Generate Tiles with gdal_translate and gdaladdo
Use this method to output mbtiles instead of a COG for serving raster tiles.
|
|
Other Methods
These methods create satisfactory outputs and can be faster, but can cause projection shifts. These may still be satisfactory for imagery where precise accuracy is not as important. In addition, the QGIS tool exports the rendered map, not just the raster, allowing for the creation of tiled custom basemaps.
- gdal2tiles
- QGIS Generate XYZ Tiles (directory & mbtiles)
|
Resources
https://alastaira.wordpress.com/2011/07/11/maptiler-gdal2tiles-and-raster-resampling/
https://gitlab.com/GitLabRGI/geopackage-python/blob/master/Packaging/tiles2gpkg_parallel.py
https://gitlab.com/GitLabRGI/geopackage-python/blob/master/Tiling/gdal2tiles_parallel.py