python - Concatenating 2d numpy arrays to a 3d numpy array -
i have large set of 2d arrays being created loop.
>>> x in list_imd: ... arr = arcpy.rastertonumpyarray(x) ... print arr.shape (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135) (129, 135)
i want convert these 2d arrays 1 3d array.
>>> arr_stacked.shape (19, 129, 135)
try using simple numpy.array
constructor:
import numpy np np.array([arcpy.rastertonumpyarray(x) x in list_imd])
here example works me:
a = np.array([[1, 2, 3], [3, 4, 5]]) >>> np.array([a, a]).shape (2, 2, 3)
Comments
Post a Comment