Not the Shortest Path: Convert a Directory of Satellite Images to a Cloud Optimized Geotiff (COG)

Unified COG after trial and error

What is ‘Not the Shortest Path’?

I really enjoy writing and sharing some of my ideas or work, but I have been struggling to create a consistent habit out of it. I find it difficult to let go of what others might think. I am committing to letting go of my fears of judgment. I am not a writer, nor just a developer.

The Problem

For a project on land-use change and reforestation in the greater Montreal area, we were given access to 25cm aerial imagery. The imagery came in a separate folder with thousands of images.

Tree output of folder
  1. Use a mosaic approach
Example image in a rural area.
  • Single merged file
  • Added overviews(its a COG after all)
  • No distortions or artifacts

First Attempt — Project, Merge, and Overviews

In the first attempt, I used the logic of projecting all the raw imagery into the desired EPSG:3857, merging the output of the projection, and finally adding the overviews to the merged file. The series of GDAL commands I used are shown in the code:

COG with artifacts around the board of each individual image

Second and Final Attempt — Merge, Project, and Overviews

We were rather convinced that the artifacts were the result of executing the projection before the merge. Our hypothesis was to switch the faulty merge and the projection step.

COG without the artifacts around the borders of the image


One of my key takeaways is no matter how powerful the tool you use to process imagery or other data for that matter, we can’t hide all of the intricacies to the end-user. GDAL is a tremendously flexible and great tool, but it is up to us end-users to figure out how to use it in a given context.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store