Is it possible to write a label expression in qgis that displays the label at a given coordinate?
One method is to use Rule-based labelling and adding two rules for "A" and "B".
Go to
Layer Properties > Labels
and change the optionNo labels
toRule-based labelling
. Then add a rule by clicking the green plus icon:Set the relevant options as shown such as
Label with
(use something'A'
) and theCoordinate X Y
. For the x-coordinate, clickEdit...
and use$x_at(0)
to place the label at the start of the linestring; for the y-coordinate, use$y_at(0)
.Repeat Step 2 for "B" but for the x-y-coordinates, use
$x_at(-1)
and$y_at(-1)
respectively for the end of the linestring.When you click Apply, hopefully you should see something like this:
There is an alternative way of doing this using symbology rather than labelling which might work for you:
- If you want different text for different features then add two fields to your data, one for your end text and one for you start text. This isn't necessary if you want just 'A' and 'B' at the ends of the lines.
- Symbolise your line layer and then add a new symbol layer -> set this to a marker line on the first vertex
- Set the symbol type to a Font Marker
- Either set the marker to 'A' or set the value to match the start field from your layers attribute table
- Muck about with size and rotation etc as you would a standard marker.
Repeat to add the end 'label'.