Update:
I store each of the bands after:
(red, green, blue, alpha) = np.transpose(img, axes = (2,0,1))
like this:
with rasterio.open('path/to/Green.tif', 'w', **profile) as dst:
dst.write(green)
and I have set:
profile["count"] = 4
This is the error I got:
Traceback (most recent call last):
File "code.py", line 126, in bands
(red, green, blue, alpha) = np.transpose(f, axes = (2,0,1))
File "<__array_function__ internals>", line 5, in transpose
File "/home/UbuntuUser/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 653, in transpose
return _wrapfunc(a, 'transpose', axes)
File "/home/UbuntuUser/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 55, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/home/UbuntuUser/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 44, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: axes don't match array