[GIS] Colour GPS track by speed

movement-dataqgis

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?

Best Answer

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...

Related Question