raster_tools.Raster.astype#

Raster.astype(dtype, 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.

  • 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