Optimizing raster data file for eVouala

You can enhance significantly browsing raster data source in a map by using raster compression!  For example, a color raster can be compressed by a factor of 20 to 30 with open source software GDAL/OGR.   As you know, a smaller raster file is drawn much quicker in a map!  Before started you will need to select a compression type.  There are two types of compression:

  • lossless - preserve original data values of pixels
  • lossy - degrade original data values of pixels to save disk space

You will choose lossless algorithms when original data values must be preserved like DEM or Landsat images for example. 

However, you will choose lossy algorithms when original data values don't need to be preserved like orthophoto or satellite imagery:

The compression ratio will depend on the raster data.  On eVouala Platform, colored GeoTIFF data source will be greatly enhanced with JPEG compression(internally tiled) in the YCbCr color space with internal overviews.  To try a lossy optimization follows those steps:

1- You need to install a software to compress all type of image format.  For this type of process, we recommended using open source GDAL/OGR software.  If you are a Windows user, browse to GISInternals website, download and installed the appropriate GDAL package.  

2- Download a sample colored raster file.  You will be able to find tons of those on the Web but for this example, I download the Natural Earth II with Shaded Relief and Water(84.78 MB)


Download this raster file from Natural Earth web site.

3- Reproject all raster file to EPSG:3857 before uploaded in the Platform. By default, all maps are projected to Web Mercator so it's a good idea to avoid heavy load on CPU by reprojecting on the fly raster data to this projection.

gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3857  NE1_50M_SR_W.tif NE1_50M_SR_W_3857.tif

4- Then open a terminal window and run gdal_translate command line to compress the sample satellite image.  The YCbCr color space is not supported for back and with imagery type:

gdal_translate -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TILED=YES NE1_50M_SR_W_3857.tif NE1_50M_SR_W_ycbcr.tif

Note that this compression option didn't support transparency. If your source raster file has alpha band, you will have to specify which band to compressed and mask other:

gdal_translate -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TILED=YES NE1_50M_SR_W.tif NE1_50M_SR_W_ycbcr.tif

5- Use QGIS and load compress and uncompress Natural Earth raster file.  You will see that it's almost impossible to see a degradation on the compress raster file even if the file is 30 times smaller

-rw-rw-rw-  167M 18 Oct  2014 NE1_50M_SR_W.tif
-rw-r--r--  5.3M  2 Mar 12:57 NE1_50M_SR_W_ycbcr.tif

6- The last step will be to add overviews with gdaladdo in your compress image to enhance raster browsing at more zoomed out scales.  With colored image, we will make sure overviews will use the same compression type better optimization.  In the next example, 4 generalization levels are added.  Level 2 generalization means 1/2 the base resolution of the file and so on. 

gdaladdo --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL -r average NE1_50M_SR_W_ycbcr.tif 2 4 8 16

Those overviews will increase the final file size.  Overviews (gdaladdo) add generalized raster layers on the top off original compress raster file, a bit like a pyramid.  That way, when you zoom out in your mapping application, the Raster Data source is still super fast to draw because you will have fewer pixels to read from your raster Data source. That’s why eVouala will draw, for example, a complete Raster Data source layer a the complete US stat in a second! 


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk