6

I have a table of stream reaches with XY coordinates for their respective tops and bottoms.

I'd like to convert the table to a feature, using the XY coordinates as the endpoints of the line.

Any suggestions as to the best workflow for doing this would be fantastic. I've Googled, but either my vocabulary is off or this isn't a task that's given others much trouble.

nmtoken
  • 13,355
  • 5
  • 38
  • 87
Jacques Tardie
  • 930
  • 1
  • 11
  • 25

4 Answers4

6

The Points2One Plugin might be helpful here. Your data will have to be in the following format:

id,      order, x,       y
stream1, 1,     x_start, y_start
stream1, 2,     x_end,   y_end
stream2, 1,     x_start, y_start
stream2, 2,     x_end,   y_end

After loading a file like this, you should get four points displayed. In Points2One Plugin, you can chose that points should be connected to lines grouped by the "id" value and sorted by the "order" value.

underdark
  • 84,148
  • 21
  • 231
  • 413
6

If you have coordinates of two points, representing start- and endpoint, you can also use "geometry by expression" from processing toolbox in QGIS 3.

Use this expression:

make_line(make_point("x_start","y_start"),make_point("x_end","y_end"))

Where x_start is the field containing x-coordinate of your startpoint, y_start the y coordinate, and so on...

enter image description here

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
2

In QGIS, try the "Points2One" plugin, and set the output geometry to lines. It requires the features you wish to be grouped together to have the same IDs.

EDIT: I see you have the data in a table. You would need to first import the table to a point shapefile (using the Delimited Text plugin). Then use the shapefile in the Points2One plugin.

Kosmo GIS also has a tool for this - "Get Lines From Points".

Darren Cope
  • 6,616
  • 2
  • 32
  • 47
2

With QGIS >3.0 (where Points2One is not avilable) you can do this without any plugin, using Toolbox > Points to path.

leo
  • 801
  • 1
  • 7
  • 14