Changing the line direction of line features using the geometry generator in QGIS
Posted by: Admire Nyakudya | in QGIS | 4 years, 3 months ago | Comments

I have been playing around with roads layers and wanted to change the line directions for some of my features. I looked around for solutions to do this in QGIS and saw that I could use the swap vector direction plugin in QGIS or ST_reverse in PostgreSQL. But I wanted to find a non destructive way to do this as I did not want to alter my data. I decided to try the geometry generator in QGIS.

Normal road symbology showing direction.

Road Line Direction

I then set out to reverse the line direction using QGIS Geometry generator.

* Activate the style tab in the layer properties.

* Change symbol layer type from Simple Line to Geometry Generator.

* Change geometry type to LineString/MultiLineString.

* In the expression write  reverse( $geometry )  to reverse the geometry of the features.

* Change Simple Line to Marker line and symbolize the marker line according to your specifications.

* Symbology should appear like the image below:


* You have your reversed lines showing in the map canvas as

* A side by side comparison of the roads layers

Current rating: 5


Have any questions? Contact us.
We would love to hear from you!
Subscribe to our Mailing list (spam-free, industry-relevant occasional emails)

Subscribe to our mailing list

* indicates required