2

Is there a way (in QGIS) to create a line from a series of points, while maintaining (at least) a column of the attribute information for each point (ie one column containing the values for a certain variable for all points)? I've been able to create lines out of the points using the 'points to path' vector creation tool, but the attribute table of the resulting line has only two cells, listing the beginning and end values: I want to keep the values for each point from which the line has been constructed.

I'm using QGIS 3.4.4 on macOS.

  • 2
    A column for each point's attributes? You would need a dynamic number of columns because the line length might vary. You could put them all in one column - rather like some of the import tools do (OGR's OSM import puts additional tags in an "other_tags" columns. Or you keep the points and reference them - eg. each point could have a field that references the parent line. – winwaed Oct 1 '19 at 15:22
  • 2
    What if you have 10,000 points? Would your resulting table have 10,000 columns? You may be able to associate the line you've created in one table with all of the point records in another table using a one-to-many relationship, but once again, that could get really unwieldy unless your particular scenario has limits on the number of points. Oasis montaj, a commercial geophysics mapping package, has the concept of a line with many data points along it. Basically each line is a time series with a number of asynchronous channels along it. Is that what you are trying to achieve? – marcp Oct 1 '19 at 15:26
  • @winwaed I think what I actually would want is a row for every point's value for a certain attribute, not a column - my mistake. – Matthew Law Oct 1 '19 at 15:39
  • @marcp see above, but in any case it would be a relatively small number of points - the test I'm trying to do now is using 82 points. – Matthew Law Oct 1 '19 at 15:41
  • 3
    You could do a spatial join between the line and the point after the line creation – J.R Oct 1 '19 at 15:50
3

Matthew, there's a terrific QGIS plugin that does exactly what you want. I've used it successfully for some time. It's called Points to Paths (note the plural Paths), and is only available at QGIS version 2.x (don't stop reading - hear me out!). It is far more capable than the 3.x Points to Path (note the singular Path) that you've tried without success.

Since Points to Paths hasn't been updated yet for 3.x, you'll have to install a separate QGIS 2.x version on your computer, but I think that it's well worth the small effort. Fortunately, 2.x and 3.x seem to play well together.

Older Mac QGIS installs can be downloaded here:

https://qgis.org/downloads/macOS/

and older Windows installs here:

https://qgis.org/downloads/

After installing 2.x (I use 2.18.28, the last 2.x release), install the Points to Paths plugin. A few notes on its use:

  1. "Point Group Field": Use this if your point data is organized into unique groups, such as specific airline flights.

  2. "Point Order Field": This field contains the point sequence that, in turn, dictates the resulting line direction. Using the airline flight example, this would be a time stamp for each point along the flight's route. Think GPS breadcrumbs.

  3. If your "Point Order Field" is formatted as text, and it contains date and/or time info (such as 2019-10-01 19:24:30) you need to specify that format in the "Date Format" fill-in box. Using my year-month-day hour:minute:second example, you would enter %Y-%m-%d %H:%M:%S I don't know why month and day are lower-case.

  4. Check the "Line per Vertex" box. This is critical! When checked, a separate line segment is created for each unique "Point Order Field" value, and (this is where the magic happens) the output line shapefile includes two attribute fields containing the beginning and ending values, respectively, from the point layer's "Point Order Field". You can now join the line layer to the point layer, and then create/calculate additional line layer fields, populating them from the point layer` (airspeed, altitude...). Voila - your line layer now carries the correct point attribute info!

This is a really useful tool (there's even no Arc Desktop equivalent), and I hope it is quickly added to the 3.x plugin repository. Until then, however, I'm keeping a separate 2.x installation on my computer.

|improve this answer|||||
  • This is very helpful, thank you so much! After a bit of fiddling around with the settings I have been able to create the line I needed in QGIS 2, but when I try to open the file in QGIS 3 it doesn't show up on the map (although the layer is in the layers panel above everything else and the attribute table is correct). Do you know if I need to do anything else in order for the line to work as desired in QGIS 3? – Matthew Law Oct 9 '19 at 14:35
  • 1
    Try restarting QGIS 3.x, then load the line layer by itself in QGIS, Do the lines now display? – Stu Smith Oct 9 '19 at 17:59
  • The line works now, thank you! – Matthew Law Oct 10 '19 at 8:02
  • Great! One additional note: In my step 4, I mention that two attribute fields are created by Points to Paths. They are named "begin" and "end". Unfortunately, those are reserved words in the Arc Desktop universe, so you might want to create two additional fields, calculate them equal to "begin" and "end", then delete "begin" and "end". I don't know if they are reserved words in QGIS; I get rid of them just to be safe. – Stu Smith Oct 10 '19 at 15:02

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.