I'm trying to create contour lines at 40 meter intervals from 60 different DEM Contour Shaded files.

Rather than doing them 1 by 1 I have tried using the batch process but I don't get any results as I don't know what to input in the 'Contour' Column.

Is this something that anybody is able to help with?

I'm assuming it is a Python Syntax but I don't know what the Syntax needs to be or how to save in a specific location.


1 Answer 1


Execute the tool manually, press Ctrl+Alt+H, click the row of the contour tool to see the tool syntax to use.

Then iterate over each raster layer added to the map like this, and use os.path.join to create a output path+name

import os
out_folder = r'/home/bera/Desktop/tempgis/contours/' #Change

for demlayer in QgsProject.instance().mapLayers().values(): #For each layer added to the map (dont add anything other than the DEMs you want to process)
    output_contours = os.path.join(out_folder, demlayer.name()+'.shp') #I name the outputs using input layer name + .shp
    processing.run("gdal:contour", {'INPUT':demlayer,'BAND':1,'INTERVAL':40,

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.