0

I have a line shapefile that contains contour lines. The attribute table of the shapefile has a field that gives the elevation of each line. I would like to draw a line across the contours and get an elevation profile. I found the Profile tool but it seems to require some sort of raster layer, and not my line shapefile layer (gives message "active layer is not a profilable layer"). It may be that I need to use some other plugin to convert my shapefile layer to the proper layer to use in the Profile tool.

Is there some sort of step-by-step tutorial on what plugins I need and how to convert a shapefile layer to the correct type of layer so that I can obtain an elevation profile by drawing a line across the contours?

Using QGIS 2.18.18

  • @Fetzer, the linked 'duplicate' does not relate to creating a profile from input vector data, rather from vector + raster. – Simbamangu Jul 11 '18 at 4:18
  • @Fetzer, if this question already has an answer, can you point me to where the answer is because I haven't found it? – Bruce Wiland Jul 11 '18 at 5:51
1

There may be better and shorter ways, but I found this webpage with detailed step-by-step instructions that worked perfectly:

https://medium.com/@hantatsang/qgis-create-dem-digital-elevation-model-with-grass-plug-in-f4ec191d08e0

Then I just used the Profile tool on the DEM created by this process.

Although the link above gives more detail and screenshots, at the suggestion of Simbamangu, here are the basic steps. They are based on a project which has a shapefile vector layer containing contour lines that has an attribute giving the contour elevation of each line. QGIS must be run with the GRASS component enabled (QGIS 3.18.18 with GRASS 7.4.0 was used in this case).

  1. Create a new GRASS project (Plugins > GRASS > New Mapset) and follow prompts.

  2. Make sure the shapefile vector layer is selected.

  3. Set the Extent (bounding box) and Resolution in the Region tab of the GRASS Tools dialog box. If there is no GRASS Tools dialog box displaying on the screen, switch it on under Plugins > GRASS > Open GRASS Tools. The lower the resolution value, the higher quality the DEM map will be but the processing time can be increased significantly in Step xx below.

  4. In the Modules tab of the GRASS Tools dialog box, import your contour shapefile into GRASS using the v.in.ogr.qgis module. Search for the module by typing the module name v.in.ogr.qgis into the Filter field. Click on the module name to open it in a new tab, and fill in the form. For "Loaded layer" field, select the contour shapefile vector layer containing contour lines that you want to import into GRASS. For "Name for output vector map" field, type in the layer name that you would like.

  5. Click on the "Run" button to start importing the vector contours. Once it finishes, click on the "View output" button so that the results show up in the Layers Panel.

  6. In the Modules tab of the GRASS Tools dialog box, create a raster contours layer using the v.to.rast.attr module. Search for the module by typing the module name into the Filter field. Click on the module name to open the form in a new tab, and fill in the form. For "Name of input vector map", select the output vector map layer that was imported in the previous step. For Attribute field, select the attribute that holds the contour’s elevation data. For "Name for output raster map", type in the the map name you would like.

  7. Click on the "Run" button to create the raster contours layer. Once it finishes, click on the "View output" button so that the results show up in the Layers Panel.

  8. In the Modules tab of the GRASS Tools dialog box, create the DEM map using the r.surf.contour module. Search for the module by typing the module name into the Filter field. Click on the module name to open the form in a new tab, and fill in the form. For "Name of input raster map containing contours" field, select the output raster map that you created in the previous step. In "Name for output raster map" field, type in the map name that you would like.

  9. Click on the "Run" button to create the DEM map. Once it finishes, click on the "View output" button so that the results show up in the Layers Panel. NOTE: This module will run extremely slowly taking several hours if the resolution is set too high (i.e., a low value) in Step #3 above. If you change the resolution in the Region tab, you must repeat the steps starting at Step #4 above. Obviouly, the resolution affects the quality of the final DEM.

  10. To permanently save the DEM map as a GeoTiff for use outside of GRASS, right click on the DEM layer you created in the step above using "Save As".

  11. Install the Profile tool to obtain profiles using the DEM created above.

  • Good that you found a solution! However, we discourage link-only answers here, as links can go dead ... could you edit the post to provide at least an overview of the steps within QGIS so we have this for the future? – Simbamangu Jul 12 '18 at 8:25
  • +1. To shorten the steps considerably, look into using the Processing toolbox - no need to get into the GRASS map setup steps, you can simply use the tools such as v.to.rast directly. You can also chain these steps together into a processing model. – Simbamangu Jul 13 '18 at 7:04
  • I have tried using the Processing toolbox without getting into GRASS, but it always gives me an error message on the first step (v.to.rast.attr): "The following layers were not correctly generated. Rasterized" and I don't know why. – Bruce Wiland Jul 16 '18 at 13:15
  • dead link above – philshem Apr 24 at 15:24

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.