geoutils.Raster.to_file#
- Raster.to_file(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.
- Parameters:
filename (
Union[str,Path,IO[bytes]]) – Filename to write the file to.driver (
str) – Driver to write file with.dtype (
Union[type[Any],dtype[Any],_SupportsDType[dtype[Any]],tuple[Any,Any],list[Any],_DTypeDict,str,None]) – 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 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)].
- Return type:
- Returns:
None.