Terrain slopes in percentages

I am trying to build a script that analysis slopes of a terrain based on the percentage and assigns colour based upon the various ranges of slopes in which the respective portions of terrain falls into.

I tried using plugins viz. Bison and Groundhog. They do not provide any facility to change the various slope percentages. Therefore, I am using native components to build the script for slope percentage colouring.

The trouble I’m right now facing is that the script wrongfully colours the maximum slope with the colours assigned to the minimum slopes. The colours assigned to high slopes are being used for shallow slopes.

What should I do to make it work correctly?

Moreover, I have architecture background, and therefore know no programming language like C#, python, visualscript, etc. I am therefore, seeking a solution that doesn’t use any code so I can comprehend what exactly is going on.

I created the terrain by using patch command on a set of contour lines raised at different levels.

TERRAIN ANALYSIS_ARCHZ2_ATTEMPT_NOV_3.gh (644.3 KB)

Hi,

your last color swatch was disabled. Just enable it and it should work.

image

And i have noticed that you have a lot of T-Values out of 0 to 25 bounds…

TERRAIN ANALYSIS_ARCHZ2_ATTEMPT_NOV_3_RE.gh (643.6 KB)

1 Like

There is also this gradient-component… (first time I tried, nice Presets!)


Gradient.gh (637.1 KB)

Thanks. What is the meaning of T values?

I have tried it. It doesn’t allow any way to enter customized slope percentages.

Sorry, tangents.
You have them growing up to 400+. That is the reason i have added extra domain 25-410, hence extra white color for that branch in a tree.

1 Like

This is a fairly straightforward way. Note, that there is a slight difference in getting the values in degrees VS converting to the more widely used “percent”, (at least in landscape architecture).

1 Like

Cool! Thanks man! Another query. I have made this script as a novice, just doing hit and trial. Is there a way to verify that the script is doing correct calculations? How do I extract just one face and perform calculations on it in order to verify that the script is not calculating inaccurate slopes?

Taking just one face in order to manually check slopes, using list item generates error.

Your quoted script is using C# component. I don’t know any computer language as I have my educational background in architectural design and landscape architecture. Therefore I’ve been in pursuit of a method which either uses a downloadable plugin that I can explain to someone else or just native components.

I have begun to understand Grasshopper a tiny wee bit after struggling to learn it since last two years. :pleading_face:

That example is a bit old, and the C# component is, quite frankly, a bit over kill. The only thing it is doing is exploding the mesh faces into individual meshes.
In ghPython, it would only be 2 lines: (well, 3 with the proper import statement).

import Rhino

x.Unweld(0, True)
a = x.ExplodeAtUnweldedEdges()

The key is to explode the mesh so that each face becomes it’s own mesh. There are a few plug-ins that do this if you are against coding anything.

The rest of the example is all native components.

The terrain I posted in the original post was built from scratch in Rhino using various contour lines. Therefore the results came out to be quite smooth.

I extracted this terrain from Google Earth inside sketchup. Then I imported the sketchup file as a triangulated mesh.
The slope analysis results come out to be quite ‘pixelated’ and uneven.
Any way to generate smooth and neat slope colouring for such models?
This is a terrain of a small portion of Manali in Himachal Pradesh, India.

TERRAIN MODEL 4NOV. MANALI TESTING.3dm (1.3 MB)

I am seeking a method which generates slope colouring as seen in the following example. This is taken from a book about landscape architecture in which slope analysis has been explained. I did not draw it. The darker shade of brown has more slope.

1 Like

If it is an overkill, then what do you suggest as a better way in place of the C# component?

Where do I type these lines? Moreover, is there any specific readymade component that you suggest that can replace these code of python? These lines will be used in place of C# component. Right?

Another thing. As of now since I do not have any computer coding background, your script looks tricky to me in comparison to the method I shared in the original post. Is there any potential instability or fault in my script, after it has been improvised by Jakinta?

I will then learn, understand and use the method which has lesser errors and instabilities.

Slope percent = 100 * tan (slope angle) | slope angle measured from horizontal

Slope percent is expressed as the equivalent vertical rise in 100 units horizontal.

Adding to this with an example.

If I am walking on a ramp which has flat horizontal distance of 200 metres, and I achieve a vertical height of 5 metres, then I get slope percentage of

(5÷200) x 100 = 2.5 percent.

In a ghpython component, right click on the x input and set it to “Item Access” and set the type hint to “Mesh”.
Add the code listed above.

your script looks tricky to me in comparison to the method I shared in the original post. Is there any potential instability or fault in my script, after it has been improvised by Jakinta?

That improvised example is fine. The major difference is that it is outputting radians, (which you can then convert to degrees or Percent, as mentioned previously, and in the example I described).
The other difference is in approach to coloring the mesh. I prefer to use the consecutive domain/find domain/ gradient combination as it a little more flexible/easier to manipulate than making sure you are manually picking colors for each range.
It’s not that it’s better or worse, (that is subjective based on what your desired outcome may be), it’s just the way that made the most sense to me.

There are a couple plug-ins that do slope analysis, but the few I looked at, I didn’t like that the colors were pre-defined, (maybe those were old versions, I haven’t looked in awhile).
Whatever type of mesh analysis you are doing generally follows a few steps:
1 - optimize an input mesh (get/recreate a clean mesh with consistent sized faces)
2 - measure something about the mesh (slope, angle from sun, etc…they mostly take a similar approach of measuring angles between vectors)
3 - categorize the values into desired domains
4 - make a color for each domain
5 - color your output mesh

I really like slope analysis as a way of teaching some mathematical/computation concepts to Landscape architects. Beyond coloring the mesh, which is fine for visualization, you should also consider how you might seperate/isolate certain slope ranges.

As for your image of the slope sample.jpg…that is actually a pretty tricky problem to solve.

1 Like

I am illustrating how we do it manually on paper using a plastic ruler and pencil colours.

1

4

5

6

yes, very clear explanation. I am familiar with that process. What I should have said was that programatically, using native GH or custom components, that is a bit of a tricky problem to solve.
Not to say that it can’t be done, it’s just that I don’t believe it is a simple process. When you do it manually, you are intuiting/estimating a best fit perpendicularity between contours. And, you will have to accomodate a few types of “relationships” between contours, (primarily how to deal with closed contours).
I would speculate that a good starting point might be to stick with a 2d exploration, (flatten contours to same plane).
In our practice, we choose to use the mesh coloring methods described in previous posts.

1 Like

The closest I can draw the relationship between that pencil+paper method and Rhino is that curves of upper and lower contour are split, then one lofted surface is given colours based upon our colour classification I just explained.

That lofted surface is the one we actually shade using pencil colours on paper.