# Making simple line more complex using QGIS? [closed]

I am trying to make my own version of code to generate elevation profile for a line drawn over a DEM and I got stuck very early on.

As a simple use case: I have a line that consists of just two points that are, say, 5 km apart. Since my DEM has a resolution of, say, 90 meters, I'd like my sampling points to be 90 meters apart, along the line.

I understand that there are tools in QGIS and GRASS that can achieve this easily (Calculating elevation profile along line from a DEM?) but they just give out the distance of each point along one axis in the final graph.

Ideally, I need to identify all the pixels on the DEM that this line passes over. If this is not possible, at least getting the location of all sampling points along the shapefile would be what I am aiming for - a kind of 3D shapefile with the elevation value for each point along with (lon,lat).

At the very least, it would be great to have an algorithm/pseudo code to make a simple line more complex by adding points to it every x distance from its origin.

## closed as too broad by PolyGeo♦Nov 22 '16 at 0:31

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Have you tried the QGIS Profile tool? It's a plugin and should do what you are looking for. It will output a graph, or elevations with coordinates and as far as I know it will only report one value per pixel. – nhopton Feb 24 '16 at 12:30
• I could not figure out a way for profile tool to show the coordinates for the points. It just shows the distance from origin along one axis. I mentioned this in my original post. – Gaurav K Feb 24 '16 at 12:45
• Once you have the profile line showing, go down and click the 'Table' tab. Then click 'Copy to clipboard (with coordinates)'. Paste to a text editor or spreadsheet. The document thus created will have four tab-delimited columns: distance from origin, x, y and elevation. If your DEM was lat/lon the distance column probably won't make much sense. – nhopton Feb 24 '16 at 19:12
• @nhopton Thank you for pointing this out. I had overlooked this crucial bit of information. – Gaurav K Feb 26 '16 at 11:48

This isn't a python-script-based solution, but this will technically work:

To add more nodes along along a line, you can use the "Densify Geometries" function specifying a distance or a number of intervals between points that a new node should be added:

After that, "Convert Polygon/Line Vertices to Points" and then "SAGA - Add Grid Values to Points", (and give it some colour):

The final step needed to give the points locations would be to "SAGA - Add Coordinates to points". At the end of the process, you'll have a points shapefile with elevation (named from your grid), X, and Y coordinates. With that, you can look into ways of visualizing the data in 3D as you'll have the source data you need. You can also easily convert this to a model and examine the code from there.

• Thanks! I guess "Densify Geometries" was the elusive search phrase. I will give it a shot. If anyone has a pure Python/Arc-Py based solution, I would love to hear that out too. – Gaurav K Feb 24 '16 at 12:31
• Another QGIS based solution is to use the code at (nathanw.net/2012/08/05/… ). Nathan calls it: 'generating chainage points'. It guess the main problem is not having a standard term for the requirement. – Gaurav K Feb 24 '16 at 12:47

True- the densify tool is only available within an ArcGIS Project. If you want to create points along a line outside of an MXD there are several ArcGIS/Python scripting tools available that will allow you to do so. Here are some links to some of the tools I know about.

ftp://lnnr.lummi-nsn.gov/GIS_Scripts/CreatePointsAlongALine/

http://www.arcgis.com/home/item.html?id=13c92d8877054b979ac2f69547bd50f1

http://www.arcgis.com/home/item.html?id=afb3cb8727c54ceba30c1df1c734f97a

http://www.arcgis.com/home/item.html?id=e19b53170e004e46827b8129d6ef9bfe

http://www.arcgis.com/home/item.html?id=78a1185b95eb4bf18c7340353ab2364d