raster.write_cog()

Write an in-memory array as a Cloud Optimized GeoTIFF.

Usage

Source

raster.write_cog(
    data,
    dst_file,
    profile,
    *,
    band_names=None,
    color_interp=None,
    tags=None,
    band_tags=None,
    units=None
)

Stages data in a rasterio.io.MemoryFile, then copies it straight to a COG at dst_file.

Parameters

data: numpy.ndarray

Array to write, shaped (height, width) for a single band or (bands, height, width) for multiple.

dst_file: str | Path | UPath

Destination COG (local or S3).

profile: dict[str, Any]

Rasterio creation profile for the staging write, as for rasterio.open(..., "w"): must include dtype, count, width, height, crs, transform, and nodata. Merged onto RASTERIO_PROFILE_DEFAULTS via build_rasterio_profile().

band_names: list[str] or None = None

Band descriptions, one per band.

color_interp: list[ColorInterp] or None = None

Per-band color interpretation.

tags: Mapping[str, str] or None = None

Dataset-level tags.

band_tags: Sequence[Mapping[str, str]] or None = None

Per-band tags, one mapping per band.

units: list[str] or None = None
Band unit strings, one per band.

Raises

RuntimeError
If the write fails.