Hello everyone !

I get an issue while downloading an processed image. Here is my code with the process I apply :

import rasterio

import numpy as np

import matplotlib.pyplot as plt

#Define the paths to the TIFF files

path_highpass = ‘cube_s2_highpass.tiff’

path_horizontal = ‘cube_s2_horizontal.tiff’

path_vertical = ‘cube_s2_vertical.tiff’

#Load the data from the TIFF files

with rasterio.open(path_highpass) as src:

cube_s2_highpass = src.read(1)

with rasterio.open(path_horizontal) as src:

cube_s2_horizontal = src.read(1)

with rasterio.open(path_vertical) as src:

cube_s2_vertical = src.read(1)

#Normalize the pixel values of the Sobel and highpass filter outputs

sobel_v_norm = (cube_s2_vertical - np.min(cube_s2_vertical)) / (np.max(cube_s2_vertical) - np.min(cube_s2_vertical))

sobel_h_norm = (cube_s2_horizontal - np.min(cube_s2_horizontal)) / (np.max(cube_s2_horizontal) - np.min(cube_s2_horizontal))

highpass_norm = (cube_s2_highpass - np.min(cube_s2_highpass)) / (np.max(cube_s2_highpass) - np.min(cube_s2_highpass))

#Combine the normalized outputs into an RGB image

combined_img = np.dstack((highpass_norm, sobel_h_norm, sobel_v_norm))

When I plot the resulting combined_img I get the right image (see below) :

The thing is that when I try to download it I get the following error :

import rasterio

#Save the combined image as a GeoTIFF file

with rasterio.open(‘combined_img_rgb.tif’) as dst:

dst.write(combined_img)

----> 4 dst.write(combined_img)

AttributeError: ‘DatasetReader’ object has no attribute ‘write’

Any ideas to fix this ?

Thanks for your answers