## Recursive Subdivision of a Topographical Surface – Example 8.3

This example is partly regional analysis, partly trying to make cool images, and partly could have some practical applications. I’ve seen a few scripts floating around called “Recursive Subdivision of a Surface.” One example is on the website of co-de-it a computational group from Italy, where a surface is measured for its curvature, and after each round, if the curvature is still high, the surface is further subdivided into smaller pieces, and when not, the subdivision process stops. I decided to try the logic of this script out with some topographic surfaces to analyze slope and flatness in slightly new ways. Script function in detail For this first example, I decided to try the script on an area around the German town of Hannoversche Münden, a small village at the confluence of the Werra and Fulda rivers, where the Weser River is born. This isn’t important to know for the script, but you’ll probably get better results if you pick an area with some distinctive topography at least for your first area.

Birdseye view of Hannoversche Münden – Source: Google Earth

To get the topography, I used the “Elk” plugin for grasshopper which can analyze SRTM elevation data. If you want to know more about how to import topography please see this tutorial 20.2. The image above describes the first steps of the script. I am showing the contour lines only for reference in the first image, to get a sense of the kind of surface I am working on. The next two images show the result of two looping “rounds”. Basically, the script splits any surface region of any size into four subregions. From there, it tests the four corners and the center point of each of the sub-regions for “flatness” If all five points (4 corners + center) have a similar elevation, say they are all within 10 meters of each other in “Z” value, the division process stops and a circle is drawn. If not, each sub-surface is further divided into four sub-sub surfaces, and these are again tested, and further subdivided, until all four corner points and the center point have “Z” values (elevations) within the range of tolerance. Hopefully this is clear from the image above. I show one of the 16 sub-surfaces from Round 2 above, as well as the four corners. The highest point has an elevation of 300m, the lowest of 124m, with a 176m differential. This subsurface doesn’t come close to passing the flatness test! So it gets chopped into smaller pieces. By round 4, a small piece near the bottom right corner finally qualifies, with the lowest elevation being 123m and the highest 130m, a 7m differential. This sub-surface is removed from the looping routine, and spared further subdivision. The first sub-regions to pass the “flatness test” appear in round 4, which qualifies roughly with the flood plain of the Fulda River in Hann. Münden. In round 5 and 6 the flood plains are largely out of the looping process, and the mountain tops are also qualifying for the flatness test as well (these are soft, rolling mountains). The last holdouts are the relatively steep intermediate slopes, but even these are flat enough by round 8. By round 9 the process is over. After the subdivisions stop, I am left with this “Quadtree” image as shown on the left. Flat and steep parts of the terrain should be clearly evident. I could stop here, but I decided to take it just a little further and to draw a circle in each square and color these with a gradient. That’s about it! Oh, one last thing. Sometimes the edges of a surface, may look a little funny. This has to do with the way a patch surface is created in Rhino. If this bothers you, you can trim the edges of your surface. Further Examples I tried this with a few other topographies I am familiar with as well. In some of these, topographical features become quite clear, while in others not so much. Generally “flat” sites generated more uneven results, since the five test points might fall in the range even though there is some topographic variation between them. but 100% accuracy is not the point of this script. One thing that’s interesting, the river valley in Rougemont (a small mountain village in the pre-Alps) has its biggest circles in the river valley, and collections of big circles are where the towns tend to be. In Hannover, on the other hand, the smallest circles are near the river. Maybe the topographic variation is so slight, its only in the flood plain that you get more than 5 meters of distance… In Bueren, which is near the head of the Leine river, the river plain is clear with large circles, as is an escarpment to the south. Anyways, here is an image of the script, showing the recursive subdivision process. Not shown is afterwards circles being draw at the center points with radius based on area, but you should be able to figure that one out…