Filter Data into 'Buckets'

Hi All,

I’m looking for a way to group values into ranges defined by another set of values.
For example - list one contains a dense list of parameters (for a curve closest point). The second list contains a sparse list of parameters (for a curve closest point).

I want to group the first list into branches where the upper and lower limits are defined by the second list.

I realise this is explained poorly - so hopefully the screenshot below will help to explain it better.
Think of it (somewhat) like a histogram, where a range of points gets collected into ‘Buckets’.

My example is simplified - the second list of points will be defined manually based on external parameters, so grouping them other ways isn’t going to help.

I realise I can do this with a series of list items, and larger than, smaller than blocks, but I can’t find a way to make it dynamic…


Point Buckets.gh (8.0 KB)

Thanks in Advance.

Does something like this work for you?

point_buckets.gh (73.1 KB)

1 Like

@Gerrard_Hickson

or you can use this workflow.


Point Buckets.gh (14.0 KB)

1 Like

I’ve tried to implement both solutions, but my actual case has 3 curves, not 1.
I’ve had to make a few tweaks to accomodate this, and I’ve figured most of the problems out, but I have one problem that has me stumped.

For some reason, my points seem to be dissappearing, but somehow, they’re still showing in the point count.

Here’s the file with both versions:
Point Buckets.gh (20.9 KB)

Here you can see that 87 points are input, and 87 points are output (no duplicates)

Here, the input points are white, the output points are green - you can see that some output points are missing - even though the point count is the same.

Any suggestions?

Your original post has only one curve. Now you are moving the goal posts. :man_facepalming:

Clustering all your code is not appropriate here.
Path Mapper is notoriously fragile so should ALWAYS be avoided, IMHO.

1 Like

We’re asked to provide a minimum example, but sometimes it’s too minimum… can’t win every time…

I don’t believe path mapper is the problem. If you view the points before path mapper you see the same problem.

In any case, what would you recommend instead of path mapper?

You should probably go with @Erik_Beeren solution, which I think is cleaner (I wasn’t familiar with the Find Domain component).

Just consider if you want to add -inf and +inf at the ends to the “splitting” points list, to make sure you include points at the ends of your curves (I think eg. @Erik_Beeren solution here was omitting some points at the end of the list because of this).

For your issue - I suppose data tree management is the problem here. The easiest solution is to use Graft by Data from TreeFrog plug-in.


point_buckets.gh (20.2 KB)

I believe the following uses only vanilla components (apart the very last one, Rainbow for coloring the points and fast checking everything to be fine, but you can just delete that component)

this definition relies on the fact that all the points are sorted: if they aren’t this will fail

Point Buckets_inno.gh (15.2 KB)

2 Likes

Understand data trees better. This video tutorial by Andrew Heumann is excellent:

2 Likes

‘Rainbow’ :interrobang: :rofl:

Looks very similar to my ColorB and ColorJ components that, in turn, were derived from ‘Colourful(by HS Kim?). Full source versions (no plugin!) are here:

I use these tools everyday.

1 Like

just a simple trick. Flatten indices and split tree afterwards.


Point Buckets.gh (11.5 KB)

I don’t have this plugin but don’t see “Flatten” anywhere in your code?

I had to download it also. It was in the file of Gerrard.
Trim Tree is a better word then flatten. :sweat_smile:

Is it any different from the standard GH component DivDist? (Divide Distance)

Yeah :bangbang: Quite different. I use Shift Paths to get the same result. Don’t know why both exist?

Hi All,

@inno’s answer provides the basic structure, but I’m still unclear on how to re-order the tree without using Path Mapper since it’s apparently unreliable as @Joseph_Oster pointed out.

I reviewed the video posted, and I understand almost all of it. For me though, Path mapper has been a very helpful tool for re-shaping my data, and it hasn’t caused problems (other then when the input data shape changes).

I’d love a more acceptable solution for re-shaping a tree from {A;B} to {B;A} if possible.

Thanks

I said it’s “fragile” for the same reason you noted in this post:

Precisely :bangbang: Data trees can easily change in the course of coding.

I haven’t used Path Mapper for more that ten years, yet managed to solve many puzzles and written a lot of GH without it. Maybe “re-shaping a tree from {A;B} to {B;A}” is going down the wrong road. Don’t get stuck in rigid thinking.

P.S. I haven’t followed this thread closely but note that @inno’s answer doesn’t use it, eh?

AB_to_BA.gh (14.1 KB)

but I didn’t really understand where/why you want to use this :slight_smile:

2 Likes

The original question was related to only the part of the problem that I was struggling with (a minimum problem) - until you mentioned it, Path Mapper was outside that scope.

As expected - There was another way around re-structuring the data. I was previously using that as a simple way to visualise each ‘bucket’ for debugging.

I’ve use a different method to get the result I want for now - no path mapper required.

For explanation (in case you’re interested):
@inno’s answer gets me to the step before I need to re-structure the data for it’s final purpose.

To further explain the problem, and why I was trying to restructure the data: the output returns a structure {A;B} where A is the curve, and B is the group (or bucket) of points. However, I actually want to set corresponding values (in my case Z heights) for all corresponding buckets (B) for each curve (A). So as long as I can input a list of Z Height (lets call that C) then create a structure with the same shape as {A;B}, but containing only the heights (C), then I can work with it

1 Like

Sorry, I’m not interested. All that “talk” about A and B makes my head spin. Guess I’m less theoretical and more of a practical engineer. That’s why I finally gave up on fourth quarter calculus in college (long ago) - it got too theoretical for me.

Hi @Gerrard_Hickson,

Here a nice clean script using your 3 line problem and which is robust.


Point Buckets3.gh (15.3 KB)

1 Like