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
Write |
- sidescanpy.grids.geotiff.to_geotiff(raster, path, *, variable='backscatter', dtype='float32', nodata=nan, compress='deflate')#
Write
variableof a gridded raster as a single-band GeoTIFF.- Parameters:
- rasterSideScanGriddedRaster or xr.Dataset
A raster, or the dataset from
SideScanGriddedRaster.to_dataset()(1-Dy/xcell-center coordinates plus a CFspatial_refcoordinate holding the CRS).- pathstr or Path
Output
.tifpath; 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 (
geoextra).- KeyError
If
variableis 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– seeSideScanGriddedRaster.to_dataset. The variable’s attrs (units, long_name, …) and the raster’s channel/processing attrs are written as GeoTIFF tags.