3

I have a CSV file with WGS84 trackpoints and visualizing them with QGIS textplugin works fine. The log interval is 1sec and I like to get the current speed to get a visual feedback, how fast the vehicle was between two points (so distance/time). Any idea how I can realize this with a style?

3

I can imagine a solution using a SpatiaLite database provided each trackpoint has some sequential id number. First import your CSV file into spatialite (plenty of sources available to explain this step) then make it a spatial layer: (I assume the CSV has columns longitude, latitude for the GPS locations, and a column 'id' with the sequential numbering of the trackpoints)

SELECT AddGeometryColumn('trackpoints','geometry',4326,'POINT','XY');
UPDATE trackpoints SET geometry=MakePoint(longitude, latitude, 4326);

Now you have a spatial point layer with each point numbered along the track. Add a column to contain the distance from each point to the next one:

ALTER TABLE trackpoints ADD COLUMN dist real;

Now to get the distance between each pair of points, make a line segment from a pair and use the GeodesicLenght() function to get distance in meters. Here's how it would be done:

UPDATE trackpoints SET dist=(
SELECT GeodesicDistance(MakeLine(trackpoints.geometry, tp1.geometry)) 
FROM trackpoints AS tp1
WHERE tp1.id = trackpoints.id+1;

Now the dist column should contain for each point the distance to the next. Finally. divide dist by the time interval between points, and you should have the speed...

  • Thanks Micha! I just expected that there is an buildin feature as most GPX viewers have. I will try your approach! – Mapper Oct 16 '13 at 18:40
1

The Trajectools plugin for QGIS provides a tool to create trajectories from points:

enter image description here

Using geometry generators, the resulting LinestringM features can be styled according to the local speed:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.