The problem is about using rasterio to generate mask from GeoJSON file which contains geographic coordinates.
The function that I used is from:
from rasterio.tools.mask import mask with rasterio.open(img_path) as src: img_mask, out_transform = mask(src, [poly], crop = False)
The shape of the mask that I generated is:
(4, 256, 256)
I converted this mask to (256,256) black and white image by taking the first channel of the mask. I used for loop to do this process couple times, and then I appended all the (256,256) masks into a list. I tried to use np.stack to convert the list to a numpy array with dimension (256,256,?). However, I got an array with dimension (?,256,256). I tried to set axis=-1; however, the image shape becomes (256,?) rather than (256,256).
Is there any method that can convert the channel first array to a channel last array with numpy?