xdem.DEM.to_file

Contents

xdem.DEM.to_file#

DEM.to_file(filename, driver='GTiff', dtype=None, nodata=None, blank_value=None, co_opts=None, metadata=None, gcps=None, gcps_crs=None)#

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.

Compression default value is set to ‘deflate’ (equal to GDALs: COMPRESS=DEFLATE in co_opts). Tiled default value is set to ‘NO’ as the GDAL default value. Raster is saved as a BigTIFF if the output file might exceed 4GB and as classical TIFF otherwise.

Example: dem.to_file(to_file, co_opts={‘TILED’:’YES’, ‘COMPRESS’:’LZW’})

Parameters:
  • filename (str | Path | IO[bytes]) – Filename to write the file to.

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

  • dtype (TypeAliasType | None) – Data type to write the image as (defaults to dtype of image data).

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

  • 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 to save to disk, in addition to existing metadata in self.tags.

  • 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:

None

Returns:

None.