Skip to main content
added 697 characters in body
Source Link
Babel
  • 75k
  • 15
  • 87
  • 227

Divide the line in segments and assign each segment the daynight value of the closest point:

  1. Explode lines

  2. Add an attribute with field calculator: overlay_touches ('foo_points', daynight)[0]

  3. Assign different colors based on this attribute with Categorized layer styling.

Even easier, I introduced the expression directly in the Categorized styling dialog, thus doing step 2 and 3 in a single step:

enter image description here

If you want to filter to catch only points with the same trip id (what seems not necessary, as long as you don't have points belonging to different trips in exactly the same spot, what seems unlikely), it's a bit more complicated. Unfortunately, filtering inside overlay functions in QGIS 3.28 still does not work as described here. But you can use this expression instead:

array_sort (
    array_foreach (
        overlay_touches ('foo_points', $id),
        if (
            attribute (get_feature_by_id ('foo_points',@element), 'trip') = trip,
            attribute (get_feature_by_id ('foo_points', @element), 'daynight'),
            ''
        )
    ),0
)[0]

Divide the line in segments and assign each segment the daynight value of the closest point:

  1. Explode lines

  2. Add an attribute with field calculator: overlay_touches ('foo_points', daynight)[0]

  3. Assign different colors based on this attribute with Categorized layer styling.

Even easier, I introduced the expression directly in the Categorized styling dialog, thus doing step 2 and 3 in a single step:

enter image description here

Divide the line in segments and assign each segment the daynight value of the closest point:

  1. Explode lines

  2. Add an attribute with field calculator: overlay_touches ('foo_points', daynight)[0]

  3. Assign different colors based on this attribute with Categorized layer styling.

Even easier, I introduced the expression directly in the Categorized styling dialog, thus doing step 2 and 3 in a single step:

enter image description here

If you want to filter to catch only points with the same trip id (what seems not necessary, as long as you don't have points belonging to different trips in exactly the same spot, what seems unlikely), it's a bit more complicated. Unfortunately, filtering inside overlay functions in QGIS 3.28 still does not work as described here. But you can use this expression instead:

array_sort (
    array_foreach (
        overlay_touches ('foo_points', $id),
        if (
            attribute (get_feature_by_id ('foo_points',@element), 'trip') = trip,
            attribute (get_feature_by_id ('foo_points', @element), 'daynight'),
            ''
        )
    ),0
)[0]
Source Link
Babel
  • 75k
  • 15
  • 87
  • 227

Divide the line in segments and assign each segment the daynight value of the closest point:

  1. Explode lines

  2. Add an attribute with field calculator: overlay_touches ('foo_points', daynight)[0]

  3. Assign different colors based on this attribute with Categorized layer styling.

Even easier, I introduced the expression directly in the Categorized styling dialog, thus doing step 2 and 3 in a single step:

enter image description here