I have a set of discretized coordinates in a Nx2 numpy.ndarray
.
I would like to get the counts and indices of each of these unique coordinate sets. numpy.unique
does exactly this, but for scalar elements.
Is there some clean way to do this using numpy
?
Example:
#input
coor = np.array([[10,10],[12,9],[10,5],[12,9]])
#output
unique_count = np.array([1,2,1])
unique_index = np.array([0,1,2]) #1 could also be 3
EDIT:
unique count
, would give the counts of each of the unique values, ie: 1 of [10,10]
, 2 of [12,9]
and 1 of [10,5]
. One would then find the values these correspond to with coor[unique_index]