Take the 2-minute tour ×

I'm mapping a steep mountain range. My main contour interval is 50 m and my intermediate contour interval is 10 m. In steep areas, the interval of 10 m is too small, so I need to leave of the 10 m-interval and use 20 m or 25 m instead.

Is there a way, to do that automated in QGIS, SAGA GIS or GRASS GIS?

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

You could try to make an overlay of your contour lines with the slope grid, and only show certain contour lines depending on the average value of the slope below that contour line.

share|improve this answer
+1 for what sounds like a great solution –  underdark May 4 '12 at 11:16
Interesting solution! Would you do a spatial join to link the average value of the slope to the contour lines? –  Simbamangu May 4 '12 at 11:27
add comment

As far as I know, there is no automatic solution in QGIS for this problem. However, it should be possible to use the rule-based renderer to specify which contours are to be plotted and which should be left out.

share|improve this answer
add comment

If I understand the problem correctly, you're working with a Shapefile that already has all the contours generated. You should have an attribute table with the contour values as one of the fields - for example, 'contour':

ID      contour
 1         1000
 2         1010
 3         1020
 4         1030

In QGIS you could do a couple of things. One would be to create a copy of the Shapefile, then remove the contours you don't want:

  1. Start an edit session, open the attributes table, and open the field calculator.
  2. Select 'create a new field' and make it a whole number field; call it 'keep'.
  3. Enter in the 'expression' field an expression that will give you the number 1 if the right conditions are met - you want to keep all the contours that are multiples of 20. Thus: contour LIKE '%00' OR contour LIKE '%20' OR contour LIKE '%40' OR contour LIKE '%60' OR contour LIKE '%80' (this kind of 'matching' function isn't pretty, but QGIS lacks the modulo math function that would make this nicer - I think).
  4. Click 'OK' and you'll have a new column with 1 where the contours are multiples of 20, and zeroes where not.
  5. Search for (select) all the rows where keep = 0 and delete them. Your new Shapefile now has excluded every other contour.

Option two would be to simply not display the contours you don't want to show. This is a bit more elegant.

  1. Open the Properties dialog and select the Style tab.
  2. Select 'Rule-based' on the upper left.
  3. Add a rule (press the 'Add' button) for contours that match the conditions you want.
    • In the Rule Properties dialog enter a label, like '20';
    • In the Filter box enter an expression to match, just like the one above: contour LIKE '%00' OR contour LIKE '%20' OR contour LIKE '%40' OR contour LIKE '%60' OR contour LIKE '%80'
    • Select a symbol style you want to use, then click OK and apply the style.

At this point, the only contours displaying will be the ones that match the expression.

The great thing about the second option is that you can create rules for different scales - you can have one rule when you're zoomed out past a certain scale that shows, perhaps, only the 100 metre contours ('%00' only in the expression), and then another rule that shows the 20 metre contours when zoomed in further, etc.

If you're looking for a method to create a new 25 m contour between the 100 m contours, then you'd probably actually be better off creating a new contour file from a digital elevation model. I am not sure if there are any methods that would reliably and correctly interpolate a new 25 m contour between other contours.

share|improve this answer
add comment

Here's how I do this when I have a contour shapefile (or a Spatialite database) containing contours at vertical intervals of 10 metres and I wish to plot just the contours that occur at (say) 50 metre intervals.

Load the shapefile and query it using this fragment of SQL: '(ELEV % 50) = 0'. Where 'ELEV' is the attribute containing the elevation data.

share|improve this answer
add comment

Your Answer


