raster.rewrite_tiff()

Rewrite a GeoTIFF locally or on S3 while preserving metadata.

Usage

Source

raster.rewrite_tiff(
    src_file,
    dst_file,
    profile=None,
    band_names=None,
    color_interp=None,
    *,
    tags=None,
    band_tags=None,
    units=None,
    move=False
)

The staged write leaves an existing destination untouched on failure.

Parameters

src_file: str | Path | UPath

Source file.

dst_file: str | Path | UPath

Destination file. May equal src_file for an in-place rewrite.

profile: dict[str, Any] or None = None

Output profile overrides.

band_names: list[str] or None = None

Band descriptions. Defaults to the source descriptions.

color_interp: list[ColorInterp] or None = None

Color interpretation. Defaults to the source values.

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

Dataset tags to merge.

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

Per-band tags to merge.

units: list[str] or None = None

Band units. Defaults to the source values.

move: bool = False
Delete the source after a successful rewrite to a different path.

Raises

RuntimeError
If the rewrite fails.