Tag Archives: raster

QGIS – Creating Longsection Profiles along lines at a specified interval

There are many analysis applications that require long section data or profiles to perform 2d sectional computations. Getting this data seems to be tricky for a lot of these users, so in this tutorial I want to share a method that’s free and easy using QGIS (2.18.4 when I wrote this).

Watch the video here if you’re feeling lazy.

Prerequisites

  • Vector Data for lines (SHP file, Excel Start/End Coords)
  • Raster Data (Geotiff(s)/Esri Grids etc.) contain desired elevation data. You can use multiple rasters if desired for geology etc,
  • QGIS Version >2.18
  • “Locate Points Along Line” – Plugin Installed (demonstrated in video)

Process

In the image below we have a series of lines that we wish to extract elevation data along.

Typically we will start with data that looks like below, its really important that we have at least

  • Easting and Northings of Start/Ends or vertices.
  • A group field to determine which points belong to which lines
  • And an order field to determine which direction the lines is drawn in.

Save this file as a csv somewhere

Now click the big comma on the left to load a csv in QGIS

Ensure “comma” delimiter is checked, “First Record has field names” is checked. (typically it does) and that the X field and Y field are choosing the correct column for geometry, this typically happens automatically.

Finally check the output at the bottom to determine its write.

Very important to note here that you will need to then specify the coordinate system(CRS) this data is in. Right click the layer and select “Set Layer CRS”

Type in the filter to find the correct CRS

All the points have come in but we now need to connect the dots

Open the Toolbox (Ctrl+Alt+T)

Search for “Points To Path” in the toolbox and double click to load

Specify the layer that contains the points, ensure the group (line ID) and order(numbers to determine line direction) fields are selected correctly. Then chose a place to save the shp file.

We now have lines but we need a raster to get elevations from

Either “Drag-Drop” in the Geotiff/Esri Grid etc. you have or select the add raster button on the left

Double check the raster covers the extent of the lines! You may need to assign the CRS for this later as well.

We now have everything but the points at the desired interval to get elevations from. We now need the plugin “Locate Points Along Lines”. Install from “Manage and Install Plugins…” if you don’t have it!

Choose a name/interval spacing and ensure “Keep Attributes” and “Add Endpoints” are ticked on. Then hit run.

Check that you have the desired results and the end points

Finally we need to add the elevations to the attribute table of these points. Right Click on the layer and select “Attribute Table” and you will see current there is no elevation data column.

In the toolbox again search for “Add Raster Values to Points”

Ensure you select the 0.5m interval points layer you created. Chose the rasters to process and also chose a place to save the resulting layer.

Remove the old layer that doesn’t have elevations

Right click on the finished layer and select “Open attribute table”

You should be able to see the elevation column at the end.

Select the top left corner of the attribute table and the press “ctrl+c” to copy all the data out

Then just past in excel and clean as required

Loading