# Cull 'Hills' and 'Pits' from Point Cloud

I would like to get rid of any points that clearly deviate from the ‘ground’ of this image below: (All of the ‘pits’ and ‘hills’

(Points only)

I’m not actually sure what sort of criteria you could cull them by? Any help would be appreciated.

Hello sailor!
You could deconstruct the points, evaluate its XYZ position and the dispathch all the points that are not equal to zero or equal to that ‘ground point’ in that position.

Best regards,
Sir Ernest Shackleton

Thank-you Captain!

For your solution I think I would need a ‘base plane’ or some way of identifying what points are ‘ground points.’

It’s a tricky situation…

No problem mate
You could just draw an SDL from everey point in -Z direction to intersect the surface ground and then perform the measurements from that intersection point. All those points that its Z value is not equal to the one from the intersection points is culled.

I mean, I don’t know if I quite grasp your problem. In the image all points are touching the ground, but just it happens that the ground changes its form and becomes mountains and valleys. If you want to get rid of all the points that are located in mountains and valleys then just cull them… assuming all the ‘ground’ points are located at (x,x,0)… wich I’m not sure. Maybe you can cull the points wich its absolute distance from 0 is larger than X. You would have to deconstruct all the points to create a matrix placed on the absolute 0 and then draw a line from the original point to the deconstructed ground point. Then evaluate the length of those lines and the ones that are larger than X get culled… that should work…

Yes, my fault for not explaining correctly. None of the ‘ground points’ have the same z value.

This is a plane drawn at (x,x,0) to illustrate it better.

Got it. I think the ground points are within some kind of range… I don’t know the scale of that but my guess would be culling all the points wich it’s absolute value in Z is larger than 4m, for example. Ground points would be located betwen -3 and 3, mountains woud be from 6 to 9 and valleys from 4 to 6…

If you calculate pca principal compononet analysis you would get that plane. For landscapes when planes differs from area to area it is done iteratively. There is super nice tool in CloudCompare called Virtual Broom

https://www.cloudcompare.org/release/notes/20161218/

Yes, this looks promising.

I was hoping to automate the process in grasshopper alone if possible. From my light-skimming of the pca Wikipedia, It’s basically a line/plane of best fit through a set of points?

Does grasshopper have this functionality?

Topo.gh (36.3 KB)

Fantastic! This got about 90% of the way there.

A few hills are still at the back there but I assume this would be solved with a more accurate ‘average plane’ (green in below image)
Would it be possible to somehow give it a rotation to fit better? At the moment I can see that it’s just a flat plane with a constant z value.
Is there a way to find the average slope of geometry in grasshopper?

I’ll have a tinker. Thank-you.