How to filter numpy array by list of indices?

后端 未结 4 1069
清歌不尽
清歌不尽 2020-12-06 09:42

I have a numpy array, filtered__rows, comprised of LAS data [x, y, z, intensity, classification]. I have created a cKDTree of points

4条回答
  •  隐瞒了意图╮
    2020-12-06 09:55

    Do you know how that translates for multi-dimensional arrays?

    It can be expanded to multi dimensional arrays by giving a 1d array for every index so for a 2d array filter_indices=np.array([[1,0],[0,1]]) array=np.array([[0,1],[1,2]]) print(array[filter_indices[:,0],filter_indices[:,1])

    will give you : [1,1]

    Scipy has an explanation on what will happen if you call: print(array[filter_indices])

    https://docs.scipy.org/doc/numpy-1.13.0/user/basics.indexing.html

提交回复
热议问题