# How to calculate the number of points from a list in a certain proximity for each point in a grid of points?

I have a data set of points in an XY plane ( “Set A” ). On top of which I have laid down a grid of points. In that grid I need to adjust the height in Z axis ( X Y coordinates remain same ) for each point depending on the density of points in “Set A” from that in a certain proximity from itself.

How do I achieve it?

You can see from my first attempt, it has evolved into a horrible mess. When I try to measure distances and filter the results, the resultant list gets messed up. Quite possibly of some wrong operation I’m doing.
wifi_spline3.gh (35.7 KB)

Any help would be greatly appreciated.
P.S. I’m new to Rhino and Grasshopper

Hi randj,

before we get into your actual problem, here’s some advice. Never run data through panels on their way to a destination. Panels convert all data to text, meaning that you (A) lose all numeric accuracy beyond 6 digits (even worse for really large and small numbers as they use scientific notation), and (B) it takes a lot more work to convert the text back to whatever the data is supposed to be. For example, take this piece of your file:

The Point component takes nearly 20 seconds to convert all the text back into points. If you plug the [G] output directly into the [P] input, the component only takes 50 milliseconds:

I’m a bit confused about how you want to measure this density. Do you want to add up all the points that are nearer to each grid point than to any other? Do you want to include all points, and just weigh them depending on distance? Maybe a third option?

From your file it seems you’re including all points within a 5000 unit radius, and you count them all equally heavily in the final tally. Is that correct?

The attached file shows how to raise a grid based on the number of points that are within X units of the grid vertices. It has sliders for elevation and height exaggeration, and it also allows you to display them using a gradient.

wifi_spline3.gh (20.7 KB)

And here’s a way to count all the points inside each cell and extrude that cell based on the count:
2DBarGraph.gh (16.9 KB)

And ultimately a way to take all points into account all the time, but the further they are the less they affect the sphere size.

WeightedCount.gh (15.5 KB)

Thank you so much!!
This is exactly what I was looking for.