I have a CSV file, or point data file which includes information about line vectors which I have previously calculated. This file is outlined as such:

x, y, dx, dy, length, angle(east_from_north)

Where x, y are the co-ordinates of each point; dX, dY are the Cartesian components of the line; length is the length/magnitude, and angle(east_from_north) is the bearing of the line (east 0degrees, north 90degrees).

I also have the the original set of x, y data from which I calculated the dX, dY components, length and angle using some python trig, if that would help this process. For example:

x1, y1, x2, y2

I would like to produce lines from each point using the x, y values as the originating point with the length and angle creating the length and direction of the line.

I have used a QGIS plugin, Vector Field Renderer to produce lines with arrowheads depicting the 'magnitude' and direction using this information which has been useful for one part of my analysis; however this does not transform the point data into polylines, only produces a line symbol -- for example:

Vector Field Renderer output

Effectively I would like to reproduce this output, but as a polyline file for which I can do further analysis on. The line does not need to have arrow heads.

Edit: Solutions involving QGIS, GRASS GIS, GDAL, ArcGIS or Python/ ArcPy would be greatly received. Though, as I am currently learning (and a bear of little brain) a well-commented/ walkthrough-esque solution would be amazing!

  • A solution in Python with PyQGIS is presented in How to create points based on the distance and bearing from a survey point?
    – gene
    Commented May 10, 2014 at 15:33
  • Thank you, however this seems to involve creating the final points, and does not plot the vector between the two as a polyline within a shapefile. Or have I missed something?
    – MACooperr
    Commented May 10, 2014 at 15:39
  • It is easy to create the line between two points with PyQGIS
    – gene
    Commented May 10, 2014 at 16:08
  • look at the solution below
    – gene
    Commented May 10, 2014 at 17:18

1 Answer 1


With the solution given in How to create points based on the distance and bearing from a survey point? and memory layers.

Part of a my class to create memory layers from the Python console (How to create points in a specified distance along the line in QGIS?):

class Crea_layer(object):
   def __init__(self,name,type):
        self.name = name
        self.layer =  QgsVectorLayer(self.type, self.name , "memory")
        self.pr =self.layer.dataProvider() 
 def create_point(self,geometry):
     # add point to the layer
     self.seg = QgsFeature()
   def create_line(self, point1,point2):
       self.seg = QgsFeature()
       self.pr.addFeatures( [self.seg] )
   def show_layer(self):


   # direction cosines function
   import math
   def cosdir_azim(azim):
       az = math.radians(azim)
       cosa = math.sin(az)
       cosb = math.cos(az)
       return cosa,cosb

   original_point = QgsPoint(50,50)
   azimuth = 120
   length = 50
   cosa, cosb = cosdir_azim(azimuth)
   end_point = QgsPoint(original_point.x()+(length*cosa), original_point.y()+(length*cosb))
   # create the points layer
   pt = Crea_layer("pt_120_50", "Point")


enter image description here

Create the line layer joining the points:

   li = Crea_layer("l_120_50", "LineString")


enter image description here

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.