Given a points collection layer containing the data field ("DATADIA") with the date (YYYYY-MM-dd), how could I connect the nearest points in order of increasing date?
The expression should work with an expression for Geometry generator that draw a line.
I add a screenshot with a hand-made simulation of the expected result example
Unsuccessful solution attempt:
With the following SQL query to create a Virtual Layer that connects each point to its closest point with the first upper date I get the following result:
SELECT ST_ShortestLine(r.geometry, p.geometry) AS geom, p.DATETEMPS AS pid, r.DATETEMPS AS rid, ROUND(MIN(ST_Distance(r.geometry, p.geometry)),2) AS distance FROM Layer_1 AS p, Layer_2 AS r WHERE p.DATETEMPS > r.FECHA GROUP BY p.DATETEMPS ORDER BY distance DESC
What modifications or corrections would have to be made so that the Virtual Layer query draw for each point its corresponding line as I show in this expected result?