Q:

GDAL (Python) reduce raster by systematic sampling

Is there any way to reduce a gdal raster in Python by sampling e.g. every 5th cell in both longitude and latitude directions?  The methods supported by gdal (e.g. gdalwarp, this question) don't obviously support this.  Is anyone aware of a method?

A:

Rasterio can do this: https://rasterio.readthedocs.io/en/latest/topics/resampling.html#up-and-downsampling
Code copied from link:

import rasterio
from rasterio.enums import Resampling

upscale_factor = 1/5

with rasterio.open("example.tif") as dataset:

    # resample data to target shape
    data = dataset.read(
        out_shape=(
            dataset.count,
            int(dataset.height * upscale_factor),
            int(dataset.width * upscale_factor)
        ),
        resampling=Resampling.bilinear
    )

    # scale image transform
    transform = dataset.transform * dataset.transform.scale(
        (dataset.width / data.shape[-1]),
        (dataset.height / data.shape[-2])
    )

