convert_dt

museotoolbox.processing.convert_dt(dt, to_otb_dt=False)[source]

Return the datatype from gdal to numpy or from numpy to gdal.

Parameters

dt (int or str) – gdal datatype from src_dataset.GetRasterBand(1).DataType. numpy datatype from np.array([]).dtype.name

Returns

dt

  • For gdal, the data type (int).

  • For numpy, the date type (type).

Return type

int or data type

Examples

>>> _convert_dt(gdal.GDT_Int16)
numpy.int16
>>> _convert_dt(gdal.GDT_Float64)
numpy.float64
>>> _convert_dt(numpyDT=np.array([],dtype=np.int16).dtype.name)
3
>>> _convert_dt(numpyDT=np.array([],dtype=np.float64).dtype.name)
7