I have a point file, with Date:Time enabled. Rather than just animate the cycling through of points, I would like to have a line moving in a straight direction from one point to another in date order.
What would be the best way to go about this?
Based on Babel's answer I have tried the following:
with_variable (
'zone',
0, -- change this value to add/subtract hours to/from attribute named arrival_time to transform local time zone to UTC
with_variable(
'arrival',
Date_time + to_interval (@zone || ' days'),
with_variable(
'next',
attribute (get_feature_by_id (@layer, $id+1), 'Date_time'),
with_variable (
'mapstart',
@map_start_time + to_interval ((second (@map_end_time - @map_start_time)/2 ) || ' seconds'),
with_variable (
'line',
make_line (
$geometry,
geometry( get_feature_by_id (@layer, $id+1))
),
end
)
)
)
)
)
My data contains a Date-time column of the format YYYY-MM-DD HH-MM-SS
. With a few exceptions all are set to 13:00:00 for the time, which is not so important. The only time this is different is when I have rows of the same day, and so would then control for them with different times.
Best Answer
I have a point layer with two fields :
id
: unique integer fielddt_field
: date time field, formatyyyy-MM-dd HH:mm:ss
I just created a symbol layer for the point layer with geometry generator symbol type,
linestring
geometry type.As geometry generator expression, I wrote the following code :
id
field values ordered by the Date Time field@data
id
index position in the@data
array@data
array (or@id_index + 1
) :@next_feature
$geometry
(use@geometry
since QGIS 3.28) to the next feature geometrygeometry(@next_feature)
With temporal controller activated and the point layer temporal settings sets on the
dt_field
, you can see the line moving through the time.