Create pandas DataFrame from raster image - one row per pixel with bands as columns
- Take array of shape
(3, x, y) and flatten out the 2nd and 3rd dimension. From the numpy docs: One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.
reshaped_array = array.reshape([3,-1])
- Transpose array to get array of shape
transposed_array = reshaped_array.T
- Build DataFrame