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 raise TypeError. If False, an attempt is made to convert other inputs to a Raster; ValueError is raised if the conversion fails.

  • null_to_nan (bool, optional) – If True and 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 is False.

Returns

The resulting raster.

Return type

Raster