So what is a cloud-optimized GeoTIFF?
A cloud-optimized GeoTIFF (COG) is a format for storing and serving georeferenced raster imagery on the web. It is a regular GeoTIFF file that is optimized for use in a cloud-based environment, such as a web server or a cloud storage service.
The key feature of a COG is that it has a built-in internal organization that allows clients to access just the parts of the image they need, without having to download the entire file. This makes it more efficient to serve and less costly to store large raster datasets in the cloud.
COGs allow Raster Data to be steamed across the web without the need for a specialized GIS Server
TIFF, GeoTIFF, and COGs
TIFF (Tagged Image File Format) is a widely used raster image format, which supports lossless compression.
GeoTIFF is a TIFF format that includes geographic metadata, which allows the image to be placed accurately on the earth.
COG (Cloud Optimized GeoTIFF) is a variation of the GeoTIFF format optimized for use in a cloud environment. But it can also be used in all the same ways you would use a normal GeoTIFF!
|Accessibility||The whole file must be downloaded||The whole file must be downloaded||Only required parts can be downloaded|
Understanding Range Requests and Internal Tilling
Range requests and COGs
A range request is a type of HTTP request that allows clients to request only a specific portion of a file, rather than the entire file. This can be especially useful when working with large files, such as raster imagery, as it allows clients to download only the parts of the file they need.
Cloud Optimized GeoTIFFs (COGs) are designed to take advantage of range requests by including a built-in internal organization that allows clients to access just the parts of the image they need. This internal organization is achieved by dividing the image into small “tiles” and storing them separately. Each tile is a regular TIFF image, with its own header and metadata, and it can be requested independently.
When a client makes a range request for a specific tile, the server sends back only that tile, rather than the entire file. This can save time and bandwidth, as the client only needs to download the part of the image they are interested in.
For example, imagine a client wants to view a map of a specific location, the client can send a range request for the tile that contains that location, the server will send that tile, and the client can display it on the map.
Internal tiling and COGs
The internal tiling system of a Cloud Optimized GeoTIFF (COG) is a way of organizing the image data that allows clients to request only the parts of the image they need, without downloading the entire file. This is achieved by dividing the image into small “tiles” and storing them separately.
Each tile is a regular TIFF image, with its own header and metadata, that can be requested independently. The size of the tile is typically 256×256 pixels, but it can be set to any size depending on the user’s needs. Each tile is stored as a separate image file in the COG, and each file has its own header.
When a client requests a tile, the server sends back only that tile, rather than the entire file. This can save time and bandwidth, as the client only needs to download the part of the image they are interested in.
The tiling system also allows for creating overviews and different resolutions of the image. Overviews are lower-resolution versions of the image that can be used when the client is zoomed out, and higher-resolution versions when the client is zoomed in, this allows for better performance and reduces bandwidth usage.
The tiling system in COGs also enables the use of range requests, this is a feature that allows clients to request only specific portions of the image rather than the entire file. This can be especially useful when working with large raster images.
The internal tiling system of a COG is a way of organizing the image data that allows clients to request only the parts of the image they need using range requests, saving time and bandwidth and improving performance.
Converting COGs to Tiffs and Tiffs to COGs
To convert a TIFF file to a Cloud Optimized GeoTIFF (COG) using GDAL (Geospatial Data Abstraction Library), you can use the
Here is an example of how to use
gdal_translate to convert a TIFF file to a COG:
gdal_translate -of COG input.tif output.tif
This command will create a new file, “output.tif”, which is a COG, from the input file “input.tif” which is a regular TIFF.
Additionally, you can use
gdaladdo to create overviews of the image and
gdal_translate to create an optimized version of the file.
gdaladdo -r average input.tif 2 4 8 16 gdal_translate -of COG -co TILED=YES -co COPY_SRC_OVERVIEWS=YES input.tif output.tif
You can also use
rio_cogeo.py a Python library to convert tiff files to COGs, it is built on top of GDAL and it provides a more Pythonic way to convert tiffs to COGs.
pip install rio-cogeo rio cogeo create input.tif output.tif
To convert a COG back to a regular TIFF, you can use the same command but with the
output.tif as the input file and the desired name of the output TIFF file.
gdal_translate -of GTiff output.tif output_regular_tiff
What is the benefit of cloud-optimized GeoTIFF?
COGs have been designed and optimized for cloud-based workflows and storage, and they come with several benefits for geospatial data users:
- Improved performance: COGs are structured to enable more efficient data retrieval from cloud storage. They are internally tiled and have multiple resolution levels, allowing users to access only the needed data rather than downloading entire files. This reduces bandwidth usage and accelerates data processing.
- Cost savings: Since COGs allow users to access and process only the necessary data, less bandwidth and storage are consumed, leading to cost savings in cloud infrastructure. Cloud Optimized GeoTIFFs do not require a server to provide access to the data, this reduces the cost of hosting data.
- Scalability: COGs are optimized for distributed processing and can be integrated seamlessly into cloud-based services, making it easier to scale up geospatial data processing tasks. ( Note that a serverless environment means that all processing is done on the client! )
- Data accessibility: COGs can be accessed and processed using various open-source libraries and tools. They support range requests, meaning users can access specific parts of a file without downloading the entire dataset, which is especially useful when working with large datasets.
- Interoperability: COGs conform to the GeoTIFF standard, which ensures broad compatibility with existing geospatial tools, libraries, and applications. This promotes easier data exchange between platforms and encourages collaboration within the geospatial community.
- Reducing data duplication: COGs enable users to work on a single copy of the data stored in the cloud, reducing the need for data duplication and management, which helps keep data storage more organized and up to date.
In summary, Cloud Optimized GeoTIFFs provide a more efficient, cost-effective, and scalable solution for working with geospatial raster data in cloud-based environments.
Cloud-Optimized GeoTIFF FAQs
Can a COG be edited?
No, at the moment COGs are read-only. This means that in order to edit a COG you must overwrite it