Generating 3d Terrain

Posted June 29, 2017

by Lensyl Urbano

3d model of the Hawaiian island chain.

3d model of the Hawaiian island chain, rendered in OpenSCAD.

After a lot of hours of experimentation I’ve finally settled on a workable method for generating large-scale 3d terrain.

Data from the NGDC’s Grid Extraction tool. The ETOPO1 (bedrock) option gives topography and bathymetry. You can select a rectangle from a map, but it can’t be too big and, which is quite annoying, you can’t cross the antimeridian.

The ETOPO1 data is downloaded as a GeoTIFF, which can be easily converted to a png (I use ImageMagick convert).

The Hawaiian data with the downloaded grayscale.

The Hawaiian data with the downloaded grayscale.

Adjusting the color scale. One interesting property of the data is that it uses a grayscale to represent the elevations that tops out at white at sea-level, then switches to black and starts from there for land (see the above image). While this makes it easy to see the land in the image, it needs to be adjusted to get a good heightmap for the 3d model. So I wrote a python script that uses matplotlib to read in the png image as an array and then I modify the values. I use it to output two images: one of the topography and one of just land and water that I’ll use as a mask later on.

Hawaiian Islands with adjusted topography and ocean-land.

Hawaiian Islands with adjusted topography and ocean-land.

The images I export using matplotlib as grayscale png’s, which can be opened in OpenSCAD using the surface command, and then saved as an stl file. Bigger image files are take longer. A 1000×1000 image will take a few minutes on my computer to save, however the stl file can be imported into 3d software to do with as you will.

Note: H.G. Deitz has a good summary of free tools for Converting Images Into OpenSCAD Models

Citing this post: Urbano, L., 2017. Generating 3d Terrain, Retrieved April 20th, 2018, from Montessori Muddle: .
Attribution (Curator's Code ): Via: Montessori Muddle; Hat tip: Montessori Muddle.

Leave a Reply

You must be logged in to post a comment.

Creative Commons License
Montessori Muddle by Montessori Muddle is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.