12

I have a river network in QGIS. I draw opposite direction of one of the rivers. Now I want to change the direction of that river.

How can I do that in QGIS 3?

(As I know it is flip in ArcGIS)

6
  • In QGIS 3.0 there is Reverse line direction tool (under Vector geometry tool) to do the job. I first thought this question was duplicate of How can I switch line direction in QGIS?. Strangely Reverse line direction tool is not there... (name change, pehaps?)
    – Kazuhito
    Mar 20, 2018 at 0:49
  • @Kazuhito the tool was not available when the linked question was asked. You needed a plugin for that, or the processing script added to the toolbox lately.
    – AndreJ
    Mar 20, 2018 at 7:08
  • Dear @Kazuhito Reverse line direction tool works for all rivers and after running that tool, I have all the rivers flowing upstream (which is not correct). There was a possibility to select only one feature as well. But doing the reverse of the selected feature make new shapefile, only containing selected feature Mar 21, 2018 at 19:54
  • Edit the original shapefile, deleting the selected river and pasting in the corrected river from the new shapefile.
    – csk
    Mar 21, 2018 at 20:08
  • Thanks for the feedback. Just as an addition to suggestion by @csk can you perhaps select features you want to process? For instance, (1) Select features while holding Ctrl key (Windows) or (2) Use Select Features by Freehand tool.
    – Kazuhito
    Mar 22, 2018 at 1:05

4 Answers 4

10

It's built into the app now and no plugins are required.

It is accessible via the Advanced digitizing panel that is not shown by default.

https://docs.qgis.org/3.10/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#reverse-line

9

If you want to reverse selected crossection lines in QGIS3.X, I recommend the plugin--digitizingtools. Of course it works well in qgis3.x. And at its tool bar, you can see flip line tool. Enjoy youself!

3
  • 5
    now in QGIS3.4,the feature Reverse line has been supported!
    – lilith894
    Dec 26, 2018 at 8:44
  • To be clear, the Flip Line too in this digitizingtools plugin allows you to flip one or more selected lines WITHOUT having to create a new layer.
    – Malcolm
    Feb 19, 2020 at 18:26
  • 1
    You don't need to create a new layer if you use the 'Reverse line' tool in the Advanced Digitising Toolbar or if you use the Edit Features in Place option with the Reverse line processing algorithm. Both have been available since the original release of 3.4 in October 2018. qgis.org/en/site/forusers/visualchangelog34/… and qgis.org/en/site/forusers/visualchangelog34/…
    – she_weeds
    Apr 6, 2020 at 7:09
3

Select line that you want to flip. Use field calculator -> go to last position -> reverse($geometry) Filed calculator

3

I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume we have five features in the 'roads' layer accordingly, see the image below.

input

With the following Query and using ST_Reverse(), it is possible to achieve the result

SELECT id, Name, length, ST_Reverse(geometry)
FROM roads

The output Virtual Layer will maintain initial attributes and reverse geometries.

result


Checking whether the query works proper possible with writing a small extra query

SELECT r1.id,
       st_astext(start_point(r1.geometry)) AS original, 
       st_astext(start_point(ST_reverse(r2.geometry))) AS reverse 
FROM roads AS r1
JOIN roads AS r2 ON r1.id = r2.id

The output table will prove that the original geometry was swapped for a new layer, see table below

proving

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.