Making a map in the equirectangular projection

When it comes to making spherical models or world globes, textures usually be made to have special proportions. In the case of maps, it is natural to use the equirectangular projection to minimize distortions.

In this tutorial we will learn how to make maps with such projection from data provided by the project. This goal can be achieved using various GISes. But here we will just use utilities from the GDAL library.

  1. In the first step, we need to create a VRT-file from the GeoTiff data
    gdalbuildvrt gtiffs8.vrt <gtiffs8>/8/*/*.tif
    

    Where <gtiffs8> is a directory in which the Geotiff tiles archive was unpacked.

  2. Next we do reprojection of raster data to the new projection.
    gdalwarp -r cubic -ts 0 2000 -t_srs EPSG:3786 -overwrite \
        gtiffs5.vrt equirectangular.tif
    

    Here, -r cubic is option for defining resample method to use (cubic or lanczos give sufficient resulting image sharpness), -ts 0 2000 sets the image dimensions (if width or height is set to 0, the other dimension will be guessed from the computed resolution), -t_srs EPSG:3786 is target spatial reference set (EPSG:3786 is one of possible ways to specify the equirectangular projection). Resulting GeoTiff image equirectangular.tif will have specified projection.

  3. Then we do reprojection of vector data. For example, we want to display all the lakes. For this we extract the corresponding shapefiles from shapes.tar.gz archive. We consider that the extracted lakes.* and lowlakes.* files are in the current folder.
    ogr2ogr -t_srs EPSG:3786 -s_srs EPSG:3857 \
        dst1.shp lakes.shp
    ogr2ogr -t_srs EPSG:3786 -s_srs EPSG:3857 \
        dst2.shp lowlakes.shp
    

    We got two new shapefiles for data in equirectangular projection. -s_srs EPSG:3857 defines projection for source data (web mercator).

  4. On this step we draw (burn) the resulting vector data in the desired projection on our raster data.
    gdal_rasterize -b 1 -b 2 -b 3 -burn 80 -burn 136 -burn 255 \
        -l dst1 dst1.shp equirectangular.tif
    gdal_rasterize -b 1 -b 2 -b 3 -burn 80 -burn 136 -burn 255 \
        -l dst2 dst2.shp equirectangular.tif
    

    Several -b and -burn options set image bands and color components for burning. -l layer defines shapefile layer (Most often there is only one layer).

  5. Finally, we convert GeoTiff file into a format that is convenient to display.
    gdal_translate -of PNG equirectangular.tif equirectangular.png
    

    After that, temporary files can be deleted.

All together the code looks like this.

gdalbuildvrt gtiffs8.vrt /8/*/*.tif
gdalwarp -r cubic -ts 0 2000 -t_srs EPSG:3786 -overwrite \
    gtiffs5.vrt equirectangular.tif
ogr2ogr -t_srs EPSG:3786 -s_srs EPSG:3857 \
    dst1.shp lakes.shp
ogr2ogr -t_srs EPSG:3786 -s_srs EPSG:3857 \
    dst2.shp lowlakes.shp
gdal_rasterize -b 1 -b 2 -b 3 -burn 80 -burn 136 -burn 255 \
    -l dst1 dst1.shp equirectangular.tif
gdal_rasterize -b 1 -b 2 -b 3 -burn 80 -burn 136 -burn 255 \
    -l dst2 dst2.shp equirectangular.tif
gdal_translate -of PNG equirectangular.tif equirectangular.png
rm equirectangular.tif
rm dst1.*
rm dst2.*