← Blog
A cream topographic map with a square tile lifted above the purple contour lines, revealing an orange edge.
Published on
2026-11-30

Serve a Cloud Optimized GeoTIFF from object storage and verify partial reads

How much of an elevation map does a client download to inspect one city block? A Cloud Optimized GeoTIFF (COG) lets the client locate the relevant raster tiles inside a single file and request their byte ranges over HTTP. In our test, a 64 × 64 pixel window took 144 KiB to read from a 10.6 MiB object. Moving that window across tile boundaries changed the transfer to 524 KiB.

How COG files use internal tiling and HTTP range requests

A GeoTIFF stores raster values with information that places them on a map. A COG arranges TIFF metadata, internal tiles and reduced-resolution images called overviews so a reader can find the data it needs early. A full-resolution sample uses the tiles that intersect its window. A zoomed-out map can use an overview instead. The Open Geospatial Consortium’s Cloud Optimized GeoTIFF standard describes the file layout and HTTP range support.

The reader may fetch several tiles or combine adjacent byte ranges in a request. Even a one-pixel read can require a whole compressed tile. That makes window position, zoom level and block size useful inputs when you test a storage endpoint. See Rasterio’s windowed reading guide.

Consider a satellite imagery collection with one object per scene. An analyst comparing two fields at full resolution needs the original image data for those fields. A map showing the whole scene at thumbnail size can use a smaller overview level. If zoomed-out views still pull large amounts of data, check for missing overviews before changing the tile size. A regular GeoTIFF file may already be tiled, so inspect its internal organization before deciding to convert it.

Create a tiled GeoTIFF and preserve the source grid

Start with a single-band raster. Keep the original for comparison and give the output a new filename. This GDAL COG driver command creates 256 × 256 tiles with lossless DEFLATE compression. Nearest-neighbor overviews retain sampled cell values, which suits class codes. For continuous imagery, choose an overview resampling method that fits how you intend to display it.

gdal_translate -of COG -co BLOCKSIZE=256 -co COMPRESS=DEFLATE -co OVERVIEW_RESAMPLING=NEAREST source.tif terrain.tif

Check the output with gdalinfo terrain.tif. Compare raster dimensions, coordinate reference system, pixel size, origin and nodata with the source. Look for the block size and overview levels. With GDAL 3.13 or later, run gdal driver cog validate terrain.tif to check the file structure. The separate delivery test below verifies what a remote client receives. GDAL validator reference.

Upload one object and check a one-byte request

Use a new versioned key in a test bucket so current map readers keep their existing data. In these Bash examples, set S3_ENDPOINT to your S3 API endpoint, BUCKET to your bucket name and RASTER_URL to the HTTPS delivery URL that your reader will use. Configure upload credentials on the sending machine. A private map needs a delivery URL or an authenticated client with read access.

aws --endpoint-url "$S3_ENDPOINT" s3 cp terrain.tif "s3://$BUCKET/terrain/v1/terrain.tif" --content-type image/tiff

Run this GET against the delivery URL, including any CDN in the intended path. The size limit keeps this diagnostic from saving a large response if the server ignores the range.

curl --silent --show-error --range 0-0 --max-filesize 1 --dump-header - --output /dev/null "$RASTER_URL"

For our 11,142,250-byte object, the working endpoint returned 206 Partial Content, Content-Range: bytes 0-0/11142250 and a one-byte body. When we made the endpoint ignore the same Range header, it returned 200 OK with a Content-Length of 11,142,250 and no Content-Range. Check the origin and CDN separately if the two paths behave differently.

Verify remote pixels and measure the bytes served

Save the following as check_window.py and install Rasterio and NumPy. It opens band 1 at native resolution and checks the raw values and validity mask independently. This example uses files with an internal mask or a nodata value encoded in the TIFF. Store any required external mask inside the finished file before using this check.

"""Check the original raster against a window fetched from its delivery URL."""
import sys
import json
import numpy as np
import rasterio
from rasterio.windows import Window

def compare(source, url, col, row):
    window = Window(col, row, 64, 64)
    with rasterio.Env(GDAL_DISABLE_READDIR_ON_OPEN="EMPTY_DIR"):
        with rasterio.open(source) as src, rasterio.open("/vsicurl/" + url) as cog:
            if col < 0 or row < 0 or col + 64 > src.width or row + 64 > src.height:
                raise ValueError("Choose a full 64 by 64 window inside the raster")
            assert (src.shape, src.crs, src.transform, src.nodata) == (
                cog.shape, cog.crs, cog.transform, cog.nodata)
            expected = src.read(1, window=window)
            actual = cog.read(1, window=window)
            np.testing.assert_array_equal(actual, expected)
            mask = cog.read_masks(1, window=window)
            np.testing.assert_array_equal(mask, src.read_masks(1, window=window))
            return {"pixels": actual.size, "masked": int((mask == 0).sum()),
                    "blocks": cog.block_shapes, "overviews": cog.overviews(1),
                    "crs": str(cog.crs)}

if __name__ == "__main__":
    print(json.dumps(compare(sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4]))))

Run each read in a new process so the second window starts with a fresh GDAL client cache. The last two arguments are the column and row of the upper-left pixel. Use coordinates inside your own raster if the example windows fall outside it.

python check_window.py source.tif "$RASTER_URL" 576 832
python check_window.py source.tif "$RASTER_URL" 736 992
64 × 64 windowSource tiles touchedHTTP 206 GETsResponse body bytes
Column 576, row 83212147,456
Column 736, row 99243536,714

We used Rasterio 1.5.2 and an S3-compatible Moto endpoint on the same machine. Both windows matched all 4,096 original pixel values and mask entries. The first included 780 nodata pixels. The coordinate reference system (EPSG:3857) and affine transform also matched. The table sums GET response bodies from the endpoint log, including the initial metadata read. It excludes headers and HEAD responses.

A 64 × 64 window of 16-bit samples contains only 8 KiB of raw pixel values. The extra bytes came from the TIFF metadata, compressed blocks and the reader’s range selection. For a storage trial, repeat with an actual map extent at the zoom level your users select. Record the range responses, total bytes and time to display. A full-resolution export has a different access pattern.

To evaluate Object Storage with Hivenet, run the same two checks against the URL you plan to give your map client. The figures above measure local S3-compatible delivery. If your next step is processing the retrieved pixels on a GPU, see our Rasterio and GPU processing guide.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.