sidescanpy.grids.geotiff#

GeoTIFF output for gridded rasters.

to_geotiff() writes one variable of a SideScanGriddedRaster (or of the plain dataset from its to_dataset()) as a single-band, north-up GeoTIFF with CRS, affine transform and nodata, via rioxarray. rioxarray is the optional geo extra (pip install sidescanpy[geo]) and is imported only here, only when called.

Contents

to_geotiff

Write variable of a gridded raster as a single-band GeoTIFF.

sidescanpy.grids.geotiff.to_geotiff(raster, path, *, variable='backscatter', dtype='float32', nodata=nan, compress='deflate')#

Write variable of a gridded raster as a single-band GeoTIFF.

Parameters:
rasterSideScanGriddedRaster or xr.Dataset

A raster, or the dataset from SideScanGriddedRaster.to_dataset() (1-D y/x cell-center coordinates plus a CF spatial_ref coordinate holding the CRS).

pathstr or Path

Output .tif path; parent directories must exist.

variablestr, default “backscatter”

Data variable to write (e.g. "n_contributing_samples").

dtypestr, default “float32”

Output band dtype.

nodatafloat, default NaN

Nodata value recorded in the file; NaN cells are written as this.

compressstr or None, default “deflate”

GDAL compression creation option; None for uncompressed.

Returns:
Path

path.

Raises:
ImportError

If rioxarray is not installed (geo extra).

KeyError

If variable is not in the dataset.

Notes

Rows are flipped to north-up. The affine transform is built from the real cell centers (pixel size = center spacing), which is approximately, not exactly, resolution_m – see SideScanGriddedRaster.to_dataset. The variable’s attrs (units, long_name, …) and the raster’s channel/processing attrs are written as GeoTIFF tags.