raster_tools.get_raster#
- raster_tools.get_raster(src, strict=True, null_to_nan=False)[source]#
Coerce the input to a Raster.
- Parameters
src (Raster or str or os.PathLike) – A Raster, which is returned as-is, or a path to a raster file, which is opened as a new Raster.
strict (bool, optional) – If
True(default), inputs other than Rasters and paths raiseTypeError. IfFalse, an attempt is made to convert other inputs to a Raster;ValueErroris raised if the conversion fails.null_to_nan (bool, optional) – If
Trueand the raster has null values, a copy is returned with the null cells replaced by NaN. The dtype is promoted to a float type, if needed, to hold the NaNs. The default isFalse.
- Returns
The resulting raster.
- Return type