How it works...

Using ST_AsTIFF() and ST_AsPNG(), we exported rasters from PostGIS to GeoTIFF and PNG. The ST_ColorMap() function helped generate images that can be opened in any image viewer. If we needed to export these images to a different format supported by GDAL, we would use ST_AsGDALRaster().