I'm trying to fix broken sections in navigation data in QGIS. I have a model that cuts out broken sections of a point layer and inserts new points according to a line layer that I added earlier. The attached image shows how it looks like.

These new points have yet no attributes. Important are the attributes "_uid_" and "time". I need a consistent layer with consecutive points. My idea was to merge these point layers and then numerate through these fields ordering by x and/or y. I'm not sure however how the expression would look like as I'm still just diving into the world of expressions. For now I create an attribute which sorts the merged layer by $x, however I assume it will create problems when processing a line which runs in an opposite direction:

array_find( array_agg($id, order_by:=$x), $id) +1

The direction of movement changes from line to line, so I'm not sure how I can implement that in the expression. The information is scarse and very fragmented with bits to be found from different youtube videos or documentations. But its all only mildly related topics. Or is there a better way available?

Further what remains unclear to me is how do I deal with the "time" attribute as it seems to be not quite easy to iterate through time. I tried following approach:

array_find( array_agg(( array_min("time") + make_interval(seconds=0.5)), order_by:="sort"), $id) +1

which, in my imagination would find the least time in the layer and then walk down the sorted attribute, adding 0.5 seconds (recording interval) to each next step. That expression seems invalid though and I cannot make it work.

enter image description here

  • 2
    Where do you have the time information? On the brown points?
    – BERA
    Aug 20, 2021 at 11:30
  • 1
    Providing your data (or a sample of it) would help finding a solution that works for your purpose.
    – Babel
    Aug 20, 2021 at 14:59
  • Maybe this helps: gis.stackexchange.com/a/386582/88814
    – Babel
    Aug 20, 2021 at 15:08

1 Answer 1


Having a layer points1 with attributes (white dots on the screenshot below) and points2 without attribute (red dots), use Merge vector layers, resulting in the layer allpoints containg all points - those with and those without attributes.

The task is now to create an attribute that represents the sequence of the points along a line.

  1. Run Explode lines to create single lines from each segement of the initial line, resulting in the layer exploded.

  2. On the layer allpoints, create a new attribute sequence with this expression:

    array_find ( array_sort( array_agg ( sequence)), sequence)

Now you can order the points using this attribute and use this order-sequence for the interpolation of your time- and uid-attributes.

Screenshot: original sequence of the two points layers, labeled in white and red at the under the line; new sequence created as described, labeled in red above the line: enter image description here

  • Unfortunately this is indicated to be an invalid expression: array_find ( array_sort( array_agg ( sequence)), sequence)
    – WindTim
    Aug 24, 2021 at 5:44

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.