I have this dataset of coordinates of electric lines in the form of vector polylines as shown in the image below, and I need to measure the distance between the first and last vertex of each line and all the other line vertices on the layer using PyQGIS. For example, take the first vertex of the first line and measure the distance between this one and all the others on the layer; then take the last vertex of the first line and measure all the distances, and repeat the same for the second line and so on. I think that a good solution is to get the coordinates of the first and last vertices for each feature, save them as a point and then apply the method explained in this post: http://gis.stackexchange.com/questions/164404/measure-distances-between-specific-features-in-qgis-for-desktop/164406#164406 to get the distances between points. [![enter image description here][1]][1] [1]: https://i.sstatic.net/BOoXw.png