How do I re-shape an array with shape(band,row,column) to (row,column,band)?

后端 未结 2 1866
傲寒
傲寒 2021-01-26 21:06

I have a NumPy array with shape(370,275,210) and I want to re-shape it to (275,210,370). How would I achieve this in Python? 370 is the number of bands,275 is the number of rows

2条回答
  •  后悔当初
    2021-01-26 21:35

    You can use np.moveaxis()

    >>> a = np.zeros((370, 275, 210))
    >>> a.shape
    (370, 275, 210)
    >>> a = np.moveaxis(a, 0, 2)
    >>> a.shape
    (275, 210, 370)
    

提交回复
热议问题