⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂




Raster.save(filename, driver='GTiff', dtype=None, nodata=None, compress='deflate', tiled=False, blank_value=None, co_opts=None, metadata=None, gcps=None, gcps_crs=None)[source]#

Write the raster to file.

If blank_value is set to an integer or float, then instead of writing the contents of self.data to disk, write this provided value to every pixel instead.

  • filename (Union[str, Path, IO[bytes]]) – Filename to write the file to.

  • driver (str) – Driver to write file with.

  • dtype (Union[dtype[Any], None, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any]]) – Data type to write the image as (defaults to dtype of image data).

  • nodata (Union[int, float, integer[Any], floating[Any], None]) – Force a nodata value to be used (default to that of raster).

  • compress (str) – Compression type. Defaults to ‘deflate’ (equal to GDALs: COMPRESS=DEFLATE).

  • tiled (bool) – Whether to write blocks in tiles instead of strips. Improves read performance on large files, but increases file size.

  • blank_value (int | float | None) – Use to write an image out with every pixel’s value. corresponding to this value, instead of writing the image data to disk.

  • co_opts (dict[str, str] | None) – GDAL creation options provided as a dictionary, e.g. {‘TILED’:’YES’, ‘COMPRESS’:’LZW’}.

  • metadata (dict[str, Any] | None) – Pairs of metadata key, value.

  • gcps (list[tuple[float, ...]] | None) – List of gcps, each gcp being [row, col, x, y, (z)].

  • gcps_crs (CRS | None) – CRS of the GCPS.

Return type: