TransWikia.com

Changing (flipping) line direction in QGIS?

Geographic Information Systems Asked by Stepan Khachatryan on February 25, 2021

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

How can I do that in QGIS 3?

(As I know it is flip in ArcGIS)

4 Answers

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!

Answered by lilith894 on February 25, 2021

Tested on QGIS 2.18 and QGIS 3.4

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

Let's assume we have five features in "roads" layer accordingly, see 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

Answered by Taras on February 25, 2021

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

Answered by Ciurr on February 25, 2021

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

Answered by Alan Davison on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP