I have a number of line layers on which I need to perform the same task: add 4 columns with the start and end points of each line.
The expressions that I use to do this are:
$xat(0)
$xat(-1)
$yat(0)
$yat(-1)
However, I must create a new column and update it for every layer, but I am sure that it can be automated. Any ideas on how to perform the creation of 4 new columns on every layer in the layers panel in QGIS?
Best Answer
As mentioned in the comment, you could create a model from the Processing Toolbox but if you want to create a script, you could use the following which creates the
start_lat
field and updates it for each layer (comments are included which hopefully will help):You could then repeat the above by adapting it to create the other 3 fields or extend the loops and create all 4 fields at once.