When reading a raster dataset with rasterio 1.3.3, nodata values are replaced by nan
.
How to read the raster dataset so that nodata cells are having their true value in the resulting numpy array from the .read()
method?
import rasterio
src = rasterio.open(
input_file_path,
mode = 'r',
driver = 'GTiff',
count = None,
crs = 'EPSG:2056',
transform = None,
dtype = 'float32',
)
data = src.read()
data # <- print an array with 'nan' in cells with nodata.
src.nodata # <- prints -9999.0
I'd like an array where nodata cells equal -9999.0
.