Grasshopper

algorithmic modeling for Rhino

Counting Objects in Region

Hey there,

I have a relatively simple problem; but don't seem to be able to solve it or find a solution anywhere.

What I would like to do is calculate how many objects / points are in each individual grid.

One grid is the red sq.

That grid = none.

I have tried using containment/regions but cant seem to get it working.

Any Ideas??

Views: 2865

Attachments:

Replies to This Discussion

Personally I would tackle this numerically. I don't have time to make up a file but why not convert it into XY data (assign a point to each item?) and tackle it as a spatial problem, i'm guessing using domains.

Points are easier than objects because points are only ever part of a single grid cell, whereas objects may be part of several. You can use a combination of Region Inclusion and Mass Addition to find all points inside certain regions; see attached.

--

David Rutten

david@mcneel.com

Attachments:

Hi David,

I was wondering if it was possible to replace the point list in this definition with a value of its corresponding volume value so that it adds up the volumes rather the amount of points in a grid/ containment.

Any feedback or comments would be much appreciated.

cheers.

Thanks for the fast replies.

I basically want to analyse the dwelling density in my urban plan Im simulating.

I am at the moment doing it a very slow and inefficient way.

As I have to list each list seprately and calculate.

I am sure there is a much faster way.

As this is just the test.  The real plan is Much bigger and would contain a smaller grid..

Much help would be appreciated.

Hey David. unfortunately i cant open ur file:

The error in GH says:  Unable to read beyond the end of the stream

I have used region inclusion but not sure how to use mass addition .

attached is my attempt at it.

Attachments:

--

David Rutten

david@mcneel.com

Thanks !!!!! so much.. it works really well...

I think I will redo my definition so that the calculations will be based from these points.

thanks again David.  :)

The reason for wanting to be able to calculate objects is because i would want to calculate the volume (3D) percentage of each region (2D).  That would be ideal.  As that would be a more accurate illustration of showing building topology within a city plan.

thanks!

If you could assign a point for each unit of volume you choose and then normalise them on one plane and solve it that way. I would love to have a crack at this problem but I have a load of stuff to do now myself.

Let me know how you go its pretty interesting.

I have got the points working per grid.

But I have to manually list each grid.  Hence not very good.  If the grid is large.

This is the method at the moment which Im sure is not good.

But I still cant make it to work by shift listing or branching.

Not sure if I am doing it right.﻿

Will def post up my results. :)  if I get it working

Attachments:
Thanks for that . :)  awesome help guys.

Hey guys.

I have come up with a problem as there are too many points to count and the grids are too small.

So grasshopper keeps crashing.

I have already baked the points to save memory .  But there are approx. 65,000 points to be counted; and the grid size is quite small.  Whole grid would be 20000 x 25000 squares.

I was wondering if anyone can help me..  Is there a way to bake values or make this definition work?

As my solution at the moment is to calculate each small row slowly and only select the points in that row.  Abit tedious.

And unfortunately since each row would have different highest values I have changed one small grid at the top to a high number to maintain the scale for the gradients.

Attached are screen shots:

Attachments:

My previous solution was wrong, here is a better one :

Attachments:

• View All