Export Terrain Contours from Blender Using Freestyle

Last modified

16 February 2019

Introduction

Blender can be used to create contours from terrain and export them in a vector format (SVG). A vector file can be used to cut materials using a laser, CNC, or plasma cutter. It can also be post processed in programs like Inkscape to produce 2d art and maps. Blender does this by rendering using the Freestyle function.

Download Mt Taranaki.zip to use for this tutorial.

Mt Taranaki

Mt Taranaki

Apply Modifiers and Extrude the Terrain

  1. Apply any modifiers applied to the model. If you have more than one then start from the top of the stack.
  2. RMB to select model.
    Select Model
  3. TAB into Edit mode.
  4. If no vertices are selected press A to select all.
    Select All Vertices
    In Blender A toggles between select all and select none.
  5. Press E to extrude and move the mouse down until the vertices are below the red line (0 on the Y axis)
    Vertices Extruded
  6. Press S, Z, 0, then ENTER
    Vertices Sacled to 0 on Z Axis
    This scales the vertices on the Z axis by 0% to give the model a flat bottom. This is optional but useful if you want a flat base for 3d printing or cutting.
Apply displacement modifier

Apply displacement modifier.

Extruding the terrain.

Add Plane

  1. SHIFT A > M >> P
    Add >> Mesh >> Plane.
  2. S >> SHIFT Z >> 10000 >> ENTER

Add a plane and scale it so that it is larger than the terrain.

Add Array Modifier

  1. Add Array modifier Array modifier.
  2. Uncheck Relative Offset.
  3. Check Constant Offset.
  4. In the Z field type 100m (or your preferred contour distance).
  5. Increase the count to 30 (or the top of your terrain)
  6. M >> 2 >> ENTER
    Move >> Layer 2
    Move to layer 2

Add an Array modifier.

Add Boolean Modifier

  1. RMB select the terrain.
  2. Add Boolean Modifier Boolean modifier.
  3. Choose the plane we created above.
    Choose Plane
Boolean Intersect

Boolean intersection of mountain and planes.

Use a Boolean Modifier Boolean modifier to find the intersections between the planes and the mountain.

Add Camera

  1. Press Z to enter Wireframe mode.
  2. Press 7 on the numeric keypad to change to Top view.
  3. SHIFT A >> R to add a camera.
  4. Press 3 on the numeric keypad to change to Right view.
  5. LMB DRAG the camera above the terrain by the blue Z axis manipulator arrow.

Adding and positioning a camera.

Configure the Render Settings

  1. Click on in Properties.
  2. Change the resolution to square dimensions (or your preferred aspect ratio). 2000px x 2000px at 100%.
  3. Choose a location for exporting the SVG file.
    Freestyle Output Settings
  4. Check  and .

Configure the Camera

  1. Click on in Properties.
  2. Change Lens type to Orthographic
  3. Changing the End clipping distance to 100km.
  4. Switch to Camera view by moving the mouse into the 3d Viewport and pressing 0 on the numeric keypad.
  5. Increase the Orthographic Scale until you see all of your model within the camera frame.

    Camera Frame

Export by Rendering

Press F12 to render. This will export the file to the path above.

Mt Taranaki rendered as contours.

Mt Taranaki rendered as contours.

Troubleshooting

You may see some straight lines in odd places. These can be deleted in your vector graphics software, e.g. Inkscape:-
Contour Artifact

On export you may find some contours need to be closed:-
Open Contours
Converting 3d meshes to vectors is mathematically complex. You may get some joy in playing with the Freestyle settings. This is a known problem. In Inkscape:-

  1. Select all paths CTRL A
  2. Combine CTRL K them into a single object.
  3. Switch to Edit paths by nodes F2
  4. CTRL A select all the nodes
  5. Join selected nodes SHIFT J.
    If your computer grinds to a halt doing this then try again but select a smaller number of paths to combine and join in batches.

If you don't see anything on your screen when you render that may be because you have given your terrain any colour, not made it shadeless, nor placed lights. Open the exported file anyway and you will find that the lines are there.... they just didn't show in Blender because black lines on a black background are invisible.
Render Black

Going Further

  1. If you want to have a thicker line after every so many contours then after the first render change the distance between contours.
    Constant Offset 500m
    Second Array
  2. Change the line thickness in the Render settings
  3. Render to a new file and then combine them in your vector program.

Thickened Contours

Discussion

Dane
Mate! Awesome - have been trying to work out how to do something like this for ages. From a Kiwi to boot! Just need to learn Blender now...

Add a remark

Your email will be private. It is used to notify you of replies to your remark.

Plain text

  • No HTML tags allowed.