rasterio.dtypes module¶
Mapping of GDAL to Numpy data types.
Since 0.13 we are not importing numpy here and data types are strings. Happily strings can be used throughout Numpy and so existing code will not break.
Within Rasterio, to test data types, we use Numpy’s dtype() factory to do something like this:
if np.dtype(destination.dtype) == np.dtype(rasterio.uint8): …
-
rasterio.dtypes.can_cast_dtype(values, dtype)¶ Test if values can be cast to dtype without loss of information.
- Parameters
values (list-like) –
dtype (numpy dtype or string) –
- Returns
True if values can be cast to data type.
- Return type
boolean
-
rasterio.dtypes.check_dtype(dt)¶ Check if dtype is a known dtype.
-
rasterio.dtypes.get_minimum_dtype(values)¶ Determine minimum type to represent values.
Uses range checking to determine the minimum integer or floating point data type required to represent values.
- Parameters
values (list-like) –
- Returns
- Return type
rasterio dtype string
-
rasterio.dtypes.is_ndarray(array)¶ Check if array is a ndarray.
-
rasterio.dtypes.validate_dtype(values, valid_dtypes)¶ Test if dtype of values is one of valid_dtypes.
- Parameters
values (list-like) –
valid_dtypes (list-like) – list of valid dtype strings, e.g., (‘int16’, ‘int32’)
- Returns
True if dtype of values is one of valid_dtypes
- Return type
boolean