I am wondering if there is a way to convert a graphic produced from symbology in QGIS to a vector layer (ie: shapefile). I have a point layer with bearing direction in the attribute table. Following the answer from How to display an arrow pointing to a specific bearing in QGIS, I have been able to make a line graphic depicting the look direction from a photo collection. I would like the line graphics to be converted into a vector layer, so I can perform some spatial analysis.

Any thoughts?

graphic representations


  • If I understand correctly, you're only interested in the vector lines. Have you considered creating them directly without going through the troubles of raster-vector conversion? – underdark Nov 20 '13 at 17:47
  • I would like to, but I am unsure of an existing tool to do that. I am aware it can be done with Python, but was hoping for a tool, plugin, process to make the lines. Any thoughts? – Ryan Garnett Nov 20 '13 at 19:06
  • I agree with @underdark that you may be better off generating a vector directly, rather than trying to convert from graphics. Have you taken a look at GRASS' m.cogo tool? You can run it from QGIS via processing. I suspect you could use it to generate a point at the appropriate bearing, then convert the points to lines. – Darren Cope Nov 26 '13 at 21:58
  • @DarrenCope I just looked at the tool, and it does not do what I need. It needs to read the bearing from the attribute table. ETGeoWizards has something close, but it makes a pie, where I need to have a line segment. I agree that using graphics is not ideal, but at this time, there is nothing else that will generate a line from a point with bearing attributes. – Ryan Garnett Nov 26 '13 at 22:17
  • Do you have a sample of the data you could post? I suspect m.cogo can work with a bit of reformatting. Since the exact tool you want doesn't seem to exist, you may have to be a bit flexible in how you format your input data. – Darren Cope Nov 27 '13 at 1:52

To first create and then try convert line graphics is not necessary. The approach I used for similar task was to create directly lines from the points and bearing (I used azimuth and constant distance) in QGIS.


  1. for every point get x2 and y2 coordinates of the line end point - from (starting) point X and Y, azimuth and your preferable distance. That can be done with field calculator using expression or if something more advanced needed function editor tab.

In my case the expression was:

x2 = $x + "distance" * sin(("azimuth" + 90)* $pi/180)
y2 = $y + "distance" * cos(("azimuth" + 90)* $pi/180)
  1. with field calculator again create column named WKT which contains following string: LINESTRING (x1 y1,x2 y2)

Following written above it should look like:

WKT = 'LINESTRING (' ||  to_string($x) || ' ' || to_string($y) || ',' || to_string("x2") || ' ' || to_string("y2") || ')'

By x1 y1 x2 y2 is meant your line starting and ending coordinates. Save as csv and add saved file to map. QGIS should recognise the WKT column as line geometry column and create lines for every source point. After that you can save it as line shapefile or in many other formats.

| improve this answer | |

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.