I have an array of shape (a, 2) of simplified points. I also have a full array of (b, 2) the non-simplified points. What I want to do is group the points as such, where the big point shown is the simplified point and small points are the full points. Note that every point in simplified also exists in full: So I wrote this code, but I feel like it might be overly complicated: def group_points(simple, all): v1 = simple.view('int32,int32').squeeze() v2 = all.view('int32,int32').squeeze() starts = np.where(np.isin(v2, v1))[0] ends = np.roll(starts, -1) ends[-1] += len(all) grouped = [ v2.take(np.arange(start, end + 1), mode='wrap').view(all.dtype).reshape(-1, 2) for start, end in zip(starts, ends) ] return grouped What it does, is find where the occurrences of the simplified points are in the full points, and then groups them inclusively, while wrapping. The reason for this is we want to connect the last point back to the first point. Is there a better way? Continue reading...