In the code below, I am trying to write a dataset. The GTiff
file has data and the image is clear but when I run the below code, the result of
dataset.write(total.astype(rasterio.uint16), 1)
is a black image.
Please let me know how to read part of a tiff
file and write it to a file.
code:
import rasterio
from rasterio.transform import from_origin
from rasterio.windows import Window
import rasterio.features
import rasterio.warp
import numpy as np
with rasterio.open('M:/tiffs/MOS_EU_LAEA_2000/MOS_EU_LAEA_2000.tif', 'w+', driver='GTiff', height='360', width='360', count=3, dtype='uint16', transform=from_origin(-180.0, 90.0, 9.5, 9.5)) as dataset:
print(dataset)
r,g,b = dataset.read()
print(r)
print(g)
print(b)
total = np.zeros(r.shape)
print(total)
for band in r, g, b:
total += band
total /= 3
print(dataset.profile)
dataset.write(total.astype(rasterio.uint16), 1)