## Surfaces from Image Sampler – Example 4.6

So it has been a few weeks since I’ve put anything new up. No, the blog is not dead (yet!) I was just on vacation in Greece. Getting back into things I am going to ditch complex scripts for a bit and look at a useful, and fairly simple tool for generating terrain models using the image sampler. This script uses the same basic logic as Example 2.5, so if you can set that one up, this one should be no problem. Here, instead of resizing circles or squares based on an image, we are going to be moving points from a grid in the Z-axis. The number of sample points in the UV directions will determine how accurate your topography will be, which will be demonstrated in one of the last examples. I will show an image of the script at the end, but will not explain the ins and outs, but a key thing to get right is that the image you are sampling should be (in pixels) the same size and proportion as your surface in Rhino/Grasshopper to get best results. So for a 3000 x 3000 pixel image your surface should be 3000 x 3000 units (in Rhino). The other thing to note is that the image sample outputs numbers between 0 and 1, so if you want to move more distance in the Z axis, you need to set up a multiply factor. Anyways, that’s about it. Now onto the examples….

Surfaces from Sketch in Photoshop

L-R: Image drawn in photoshop. Plan with contours and drainage curves. Isometric.

L-R: Image drawn in photoshop. Plan with contours and drainage curves. Isometric.

In these first two images, I quickly sketched some shapes in Photoshop using the gradient paintbrush. In my script, white areas are higher points and black areas are lower points. I could reverse these by subtracting the results of the image sampler from 1, in which case black would be high and white would be low. I have 100 x 100 sample points, and after moving them up and down in the Z direction, I create a surface grid. From this, contours and drainage analysis could be done as explained in Example 4.1.  If you are a little more old school, you might try drawing something with charcoal and erasers, scanning the image, and creating a terrain from that…

Example 2 – Terrain from Aerial Imagery

Terrain Image: Google Earth. Libyan Desert near Sabha

Terrain Image: Google Earth – Idhän Murzuq Desert, Libya

You could also try generating a terrain from found images. These were just two images I randomly took from the Libyan desert to see what terrain might result. Note, these are NOT the actual topographies represented by these images, just an abstraction. The dune field in Libya might produce results that are close, though, based on shadows. This might not be that useful, but its an interesting test.

Example 3: Terrain from DEM files

Maybe the most useful application of using image sampling to create terrain is to convert DEM (Digital Elevation Model) data into 3D models. Since I just got back from Greece, I decided to try this out on the Peloponnese peninsula. Before starting in Rhino, I loaded and extracted the DEM data frame using ArcGIS. If you don’t have access to this (licenses are expensive!) there is a free GIS program, QGIS that you could probably use to do the same thing but I haven’t tried this yet. In GIS I applied a black and white gradient with white being the lowest points and black being the highest.

After my first try with 100 x 100 sampling points, I got results as you can see above. I tried this again with 300 x 300 sample points and got much more accurate terrain, but it also takes longer to generate. Depending on your needs, the 100 x 100 might be enough… From this I drew contours.

I tried a couple of other examples. This is Scotland, potentially the world’s next independent nation…

DEM Source: USGS Hydrosheds

And this last example, South America. Note in this particular DEM the Altiplano is considerably flattened. Still a nice drawing, I think.

Below is the grasshopper script used to generate the topography in these examples. Note that it is very similar to Example 2.5 with the Sampling being used this time to generate the “Z” Value.

Grasshopper Script