raster.write_cog()

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

Usage

Source

raster.write_cog(data: np.ndarray, dst_file: AnyPath, profile: dict[str, Any], band_names: list[str] | None = ..., color_interp: list[ColorInterp] | None = ..., tags: Mapping[str, str] | None = ..., band_tags: Sequence[Mapping[str, str]] | None = ..., units: list[str] | None = ..., checksum: Literal[False] = ...) -> None
 
raster.write_cog(data: np.ndarray, dst_file: AnyPath, profile: dict[str, Any], band_names: list[str] | None = ..., color_interp: list[ColorInterp] | None = ..., tags: Mapping[str, str] | None = ..., band_tags: Sequence[Mapping[str, str]] | None = ..., units: list[str] | None = ..., checksum: Literal[True]) -> str
 
raster.write_cog(data: np.ndarray, dst_file: AnyPath, profile: dict[str, Any], band_names: list[str] | None = ..., color_interp: list[ColorInterp] | None = ..., tags: Mapping[str, str] | None = ..., band_tags: Sequence[Mapping[str, str]] | None = ..., units: list[str] | None = ..., checksum: bool) -> str | None

Parameters

data: numpy.ndarray

Single- or multi-band array.

dst_file: str | Path | UPath

Destination COG (local or S3).

profile: dict[str, Any]

Raster metadata and native GDAL COG creation options.

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.

checksum: bool = False
Encode the COG into memory and hash those exact bytes before uploading, instead of streaming the encode straight to dst_file.

Returns

str or None
The SHA-256 digest as a multihash ("1220" + hex) when checksum is True, otherwise None.

Raises

RuntimeError
If the write fails.