Save result array (rf_array
) as in the following lines: (You don't need to reshape the array)
rf_array = df_join['Prediction'].values # returns numpy.ndarray
rf_array = rf_array.reshape(img.shape[0], img.shape[1])
# rf_array = rf_array.reshape(869, 1202)
with rasterio.open('path/to/new.tif',
'w',
driver='GTiff',
height=imgheight=rf_array.shape[0],
width=imgwidth=rf_array.shape[1],
count=1,
dtype=imgdtype=rf_array.dtypes[0]dtype,
crs=img.crs,
nodata=None, # change if data has nodata value
transform=img.transform) as new_file:
new_file.write(rf_array, 1)
When you open the two images in QGIS they will overlap.