I need to label contour lines in QGIS 2.14. I've tried a few things, including Choosing only one contour line to label in QGIS? but it labels with the IDs instead of altitude.

EDIT: I've created the contour lines using this method : loaded an MNT (RGEALTI from IGN in France that contains altitude data), then menu raster / extraction / contour Here's the MNT image: enter image description here

enter image description here

Labels window:

enter image description here

![enter image description here

EDIT: using ELEVATION instead of ID doesn't display the altitude enter image description here

EDIT: I went again through the process of extracting contour lines (raster/extraction/contour lines) but this time I added a name to the attribute as suggested below by Gabriel C. And there is an error during the process. enter image description here Here's the attribute table of the layer: attribue table

  • 2
    Can you show the settings of your label window? – ahmadhanb Nov 3 '18 at 12:44
  • 6
    I recommend not thinking about GIS SE as being some sort of online GIS tutor. For your questions to be answered here they should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. – underdark Nov 3 '18 at 12:52
  • @ahmadhanb I added the label window. Why 3 downvotes ? For the last comment above, it seems that it's exactly what I did. – Louis Nov 4 '18 at 17:22
  • @Louis I didn't downvote your question, but the community did. It was unclear how labeled the contour lines. You showed us the contour with the labels, but you did not show us the labeling windows so that we can understand the label settings. Now it is very clear where the mistake is located, you should choose the Height field or Elevation field from the Etiquette avec not the ID. – ahmadhanb Nov 4 '18 at 19:03
  • @Louis Did you ever get this to work? If yes, maybe accept an answer that solved the problem. If not, I'd be curious to see the attribute table for your contour lines. – Gabriel Nov 29 '18 at 15:17

I feel the error comes from your contour generation. If you didn't set an elevation attribute name, the attribute gets skipped and you have no way to define what elevation your contours are at. Make sure the name respects shapefile requirements (no accents, no spaces, maximum 8 characters) to avoid problems.

enter image description here

  • I just tried this. During the contour-lines extraction, I gave a name to the elevation field (ELEVATION_LR). But I still can't see it in the "labels" section in the properties of the layer. – Louis Dec 6 '18 at 14:30
  • @Louis if you look at the attribute table, is the field there and is it populated? – Gabriel Dec 6 '18 at 14:34
  • No. See the attribute table in my edited question. There are only the IDs. That's the problem. How to get the elevation here? Thanks for your help. – Louis Dec 6 '18 at 14:39
  • 1
    And did you try with a really simple field name like 'ELEV'? No accented characters, no spaces, shorter than 8 characters? – Gabriel Dec 6 '18 at 15:06
  • 1
    Perfect. Feel free to resolve the question by accepting an answer with the checkmark! I'll edit my answer to include the field name info. – Gabriel Dec 6 '18 at 15:42

Change this to your Height-Attribute:

enter image description here

  • I tried, but I don't know how. When I click this select box, there's nothing else than ID. When I click the epsilon on the right, I can go and find "ELEVATION" but when I choose this, nothing is displayed on the contour lines. – Louis Nov 5 '18 at 7:53
  • 3
    I assume your ELEVATION attribute is just empty? Can you show a screenshot of your attribute table? Where did you get the contour lines from? Or in case you created them yourself: how? – MrXsquared Nov 5 '18 at 20:23
  • I've created the contour lines using this method : loaded an MNT (cadastre in France), then menu raster/extraction / contour – Louis Nov 7 '18 at 15:29
  • I cannot check this since I dont have an account or speak french; but because you say "cadastre" I assume your input raster file does not contain any elevation information like a DEM. If you are looking for free DEM sources check SRTM or ASTER. Official french authorities should have better ones, but I assume not for free. – MrXsquared Nov 7 '18 at 16:09
  • I edited the question, but actually the MNT file is announced to contain elevation data, because it's sold as a measure of the elevation of french regions. And I plot the contours from this, so it contains elevation data. – Louis Nov 8 '18 at 17:11

Contour lines usually have a field in the attribute table where the elevation data is stored. You would then select this attribute from the dropdown menu where it says "label with" or "etiquette avec." Et voilà, the contour lines are labeled with elevation data.

Unfortunately, the elevation data is missing from your contour lines. There's nothing you can do with this layer to make it display elevation, because that information simply isn't there. You could add it yourself by adding a topographic basemap and editing the attributes of every single topoline to match the basemap, but that's a last resort. Instead, try one of the following:

  • Try to find contour lines from a different source. You may be able to download a contour layer for free. This question on OpenData SE may help you find topolines for your area of interest.

  • If contour lines aren't available for free, you should be able to obtain a DEM (digital elevation model) raster. Use the DEM to create contours.

  • If you need contours which are identical to the contour layer you already have, try this approach. Convert the contour lines to points using the extract vertices tool, then add the elevation data to those points using the point sampling plugin or Add raster values to point tool. See here for more information. Then add an attribute to the original contour layer which takes the rounded average of the elevation of all the points, using an expression like this:

     round( aggregate('pointlayer', 'mean', "elevation"), -1)

    Substitute your own point layer name and elevation attribute name where the expression says 'pointlayer' and "elevation".

  • I created those contour lines myself from a MNT elevation file, so they should have the altitude – Louis Nov 8 '18 at 17:15
  • I edited my question. I am extracting the contour lines from an MNT files that contains elevation information. So I should be able to get this information in the contour lines right? I bought this file, I don't necessarily want to go to other sources. – Louis Dec 6 '18 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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