[Qgis-user] Labelling expressions: how to select the 'last' row in a csv dataset

Gavin Macaulay gavin at macaulay.co.nz
Mon Mar 10 13:18:24 PDT 2014


Hi,

I have a csv file that looks like this:

datetime, latitude, longitude, speed
2014-03-07T06:11:56.794000, 69.6930, 19.0321, 0.0
2014-03-07T06:12:56.791000, 69.6904, 19.0291, 10.0
2014-03-07T06:13:56.787000, 69.6879, 19.0257, 10.0

A new row gets added to the file every second or so. I load this file 
into QGIS as a csv file with the watch option turned on so that every 
time the map is refreshed, the map plots any new points that have been 
added to the file.

I would like to have the most recent line in the file plotted with a 
different symbol to the rest (the data represents realtime data from a 
moving ship so it's good to highlight the latest position). I can almost 
do this using the expression based labelling, but not quite (I can get a 
row number, but not the total number of rows, so can't do something 
obvious like: $rownum == $numrows, or $id == max($id)).

Any suggestions on how I can achieve this? I could move the data into a 
SQL-based layer and choose the last row using an SQL statement, but the 
simplicity of generating the csv files is attractive.

Thanks

Gavin



More information about the Qgis-user mailing list