I have a layer with point geometry with a field STREETCODE that represents the entry number of each house. On the other hand, I have, a layer with line geometry with the field STREETCODE, representing the centerline axis of each street.

My objective is to use an expression to obtain a graphical representation to identify to which street axis each house entrance belongs.

For the demonstration I use a layer of line symbols from the Geometry Generator on my points layer:


When I test the expression it works fine for most cases. However, for some cases it would be necessary to force it to draw the shortest_line according to the STREETCODE = STREETCODE.

shortest lines issues on QGIS canvas

  • 3
    Something like : shortest_line($geometry, aggregate('LINESTREETS', 'collect', $geometry, "STREETCODE" = attribute(@parent, 'STREETCODE'))) ? Commented May 3, 2023 at 9:00
  • 1
    Yes, I confirm that it works Commented May 3, 2023 at 9:40

1 Answer 1


Solved from J. Monticolo comment:

shortest_line($geometry, aggregate('LINESTREETS', 'collect', $geometry, "STREETCODE" = attribute(@parent, 'STREETCODE')))

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.