Skip to content
  • Home
  • About
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
  • Contact Us
Geoscience.blogYour Compass for Earth's Wonders & Outdoor Adventures
  • Home
  • About
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
  • Contact Us
Posted on January 5, 2023 (Updated on July 19, 2025)

Batch create DEM from contour maps (open source)

Hiking & Activities

Turning Contour Maps into Digital Terrain: An Open Source Adventure

Ever needed to visualize a landscape in 3D, maybe for planning a garden, analyzing flood risks, or just geeking out with some cool terrain models? Digital Elevation Models (DEMs) are the key. They’re like digital sandboxes that let you play with terrain data. Now, if you’re starting with old-school contour maps – those lines that show elevation on topographic maps – you might think you need expensive software to turn them into a DEM. Think again! A whole world of open-source tools is ready to help you do this efficiently, even if you have a stack of maps to process. Let’s dive in and see how you can batch-create DEMs from contour maps using free software.

The Basic Idea

The core concept is pretty straightforward: you’re filling in the blanks between the contour lines. Imagine connecting the dots, but instead of drawing lines, you’re creating a continuous surface that represents the terrain’s highs and lows. This process, called interpolation, takes the elevation values from your contour lines and guesses the elevation of every other point in your area. Sounds like magic? It’s just clever math, and thankfully, the open-source community has made it accessible to everyone.

Your Open-Source Toolkit

So, what tools can you use? Here are a few of my favorites:

  • QGIS: Think of QGIS as your friendly neighborhood GIS Swiss Army knife. It’s packed with features, including the ability to create DEMs. I often use it with the GRASS GIS plugin, which unlocks even more terrain analysis power. The r.surf.contour module in GRASS is like a dedicated contour-to-DEM wizard. QGIS also has a built-in TIN interpolation tool, which is super handy.
  • GRASS GIS: If QGIS is the Swiss Army knife, GRASS GIS is the heavy-duty terrain analysis toolbox. It’s a bit more command-line focused, but don’t let that scare you. Its r.surf.contour module is a workhorse for converting contours to DEMs, especially when you’re dealing with large datasets. I’ve used GRASS for some pretty complex hydrological modeling projects, and it never disappoints.
  • SAGA GIS: SAGA GIS is another gem in the open-source world, especially if you’re into geoscientific modeling. It has a bunch of different interpolation methods, and its command-line interface makes batch processing a breeze. I remember one project where I needed to analyze soil erosion, and SAGA’s terrain analysis tools were invaluable. To create DEMs, you’ll need to convert contour lines to points first. Then, functions from Grid / Gridding and grid / Spline Interpolation can be used.
  • GDAL: GDAL is more of a behind-the-scenes player. It’s a library that helps software read and write different geospatial data formats. While it’s not a full GIS program, its gdal_contour command-line tool can be part of your workflow. It’s usually used to extract contours from a DEM, but you can use it in reverse: rasterize your contours and then process them to create a DEM.

Automating the Process: Batch Processing

Now, let’s say you have a whole folder full of contour maps. You don’t want to create DEMs one by one, right? That’s where batch processing comes in. This is where scripting becomes your best friend.

  • QGIS and GRASS GIS: QGIS lets you access GRASS tools through its Processing Toolbox. To automate things, create a processing model or script that loops through your contour maps and runs the r.surf.contour module on each one. It’s like setting up a DEM assembly line!
  • SAGA GIS: SAGA GIS shines with its command-line capabilities. Write a script that iterates through your contour files and calls the appropriate SAGA GIS command for each.
  • GDAL: GDAL’s gdal_contour command-line tool can be dropped into a script to automate contour generation. The script can loop through a directory of DEM files, calling gdal_contour for each to produce contour shapefiles.

Choosing the Right Interpolation Method

The way you interpolate your data can make a big difference in the final DEM. Here are a few options:

  • Triangulated Irregular Network (TIN): TIN creates a surface by connecting the contour lines with triangles. It’s great for preserving detail but can sometimes look a bit jagged.
  • Inverse Distance Weighting (IDW): IDW estimates values based on the average of nearby points, giving closer points more weight. It’s simple but can create “bullseye” patterns around your data points.
  • Spline: Spline interpolation fits a smooth curve through your data. It looks nice but might not be the most accurate in areas with limited data.
  • Kriging: Kriging is a more advanced method that uses statistics to interpolate values. It can give you more accurate results, especially with unevenly spaced data.
  • Multilevel B-Spline Interpolation: If you’re using SAGA GIS, this tool is fantastic for smoothing out your DEM and getting rid of any unwanted bumps.

Pro Tips for Batch Processing

  • Get your data in order: Make sure all your contour maps use the same coordinate system and that the elevation data is stored in the same field. Trust me, this will save you headaches later.
  • Watch out for tile boundaries: If you’re working with multiple maps that fit together, combine them before creating the DEM to avoid weird lines at the edges.
  • Limit your area of interest: In GRASS GIS, set the computational region to the area you’re actually working on. This will speed things up.
  • Handle those NoData values: SRTM data, in particular, can have gaps. Use the -snodata parameter in gdal_contour to ignore these gaps.
  • Write good scripts: Your scripts should be able to handle errors and give you useful information about what’s going on.

A Quick Example with GDAL

Here’s a simple example of how to batch-process DEMs using GDAL from the command line:

  • Make sure your DEMs are ready: They should be in a format that GDAL can read, like GeoTIFF or ASC.

  • Create a script (e.g., batch_contour.sh):

    bash

    You may also like

    Field Gear Repair: Your Ultimate Guide to Fixing Tears On The Go

    Outdoor Knife Sharpening: Your Ultimate Guide to a Razor-Sharp Edge

    Don’t Get Lost: How to Care for Your Compass & Test its Accuracy

  • Disclaimer

    Our goal is to help you find the best products. When you click on a link to Amazon and make a purchase, we may earn a small commission at no extra cost to you. This helps support our work and allows us to continue creating honest, in-depth reviews. Thank you for your support!

    Categories

    • Climate & Climate Zones
    • Data & Analysis
    • Earth Science
    • Energy & Resources
    • Facts
    • General Knowledge & Education
    • Geology & Landform
    • Hiking & Activities
    • Historical Aspects
    • Human Impact
    • Modeling & Prediction
    • Natural Environments
    • Outdoor Gear
    • Polar & Ice Regions
    • Regional Specifics
    • Review
    • Safety & Hazards
    • Software & Programming
    • Space & Navigation
    • Storage
    • Water Bodies
    • Weather & Forecasts
    • Wildlife & Biology

    New Posts

    • Is Your Garage a Good Home for Your Bike? Let’s Find Out.
    • Danner Mens Panorama Hiking Boot – Review
    • Cowboy Fringe Studded Buckle Booties – Review
    • Getting the Most Out of Your Shimano Reel Warranty: A Real Angler’s Guide
    • riqqo Snow Boots: A Stylish and Functional Winter Find? (Review)
    • Body Glove Mira 30L Backpack: A Stylishly Functional Everyday Companion
    • What’s a “Barrage” in Cycling? Cut Through the Jargon
    • PUMA Stellar Backpack: Sleek Style Meets Everyday Functionality
    • Laredo 68068 Monty Western Copper – Review
    • Decoding the Peloton: More Than Just a Fancy Bike
    • Ellie Shoes 1970s Disco Medium – Buying Guide
    • GHZWACKJ Water Shoes: Are These the Ultimate Aqua Socks for Summer Adventures?
    • What’s the Deal with Prologues in Cycling?
    • YMGSCC Sandals Non Slip Handmade Sneakers – Honest Review

    Categories

    • Home
    • About
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • Contact Us
    • English
    • Deutsch
    • Français

    Copyright (с) geoscience.blog 2025

    We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
    Do not sell my personal information.
    Cookie SettingsAccept
    Manage consent

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Always Enabled
    Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
    CookieDurationDescription
    cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
    cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
    cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
    cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
    cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
    viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
    Functional
    Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
    Performance
    Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
    Analytics
    Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
    Advertisement
    Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
    Others
    Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
    SAVE & ACCEPT