raster_tools.Raster.astype#

Raster.astype(dtype, new_null_value=None, warn_about_null_change=True)[source]#

Return a copy of the Raster cast to the specified type.

Parameters
  • dtype (str, type, numpy.dtype) – The new type to cast the raster to. The null value will also be cast to this type. If the null value cannot be safely cast to the new type, a default null value for the given dtype is used. This will produce a warning unless warn_about_null_change is set to False.

  • new_null_value (scalar, optional) – If provided, this sets the new null value to use in the result. Default is to use the already present null value, if possible, or use the default null value for the new dtype.

  • warn_about_null_change (bool, optional) – Can be used to silence warnings. The default is to always warn about null value changes.

Returns

The new dtype raster.

Return type

Raster