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

2014-03-11 Thread Gavin Macaulay

Bob,

Thanks for the suggestion. How does one get the csv provider to read 
just the first line?


Gavin

On 10/03/2014 10:25 p.m., Basques, Bob (CI-StPaul) wrote:

Gavin,

Set up the CSV file creation to append to the top of the file instead of the 
bottom, then just read the first line for the special cartography.

If you are running on Linux, there are a whole bunch of options with AWK/GREP, 
etc to get the data outputting in a more favorable fashion for reading.

My first thought was to suggest the SQL path though, this gives you lots of 
options for archiving and looking at the path/trail over time . . .

I've just completed doing something similar for a AVL tracking system.

Bobb



-Original Message-
From: qgis-user-boun...@lists.osgeo.org 
[mailto:qgis-user-boun...@lists.osgeo.org] On Behalf Of Gavin Macaulay
Sent: Monday, March 10, 2014 3:18 PM
To: qgis-user@lists.osgeo.org
Subject: [Qgis-user] Labelling expressions: how to select the 'last' row in a 
csv dataset

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
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user




___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-03-11 Thread Gavin Macaulay

Brent,

I was so focussed on trying to use labelling that I didn't think of 
other options, such as you suggested:) The two files method does the 
job, and matches the hacky way that the original file generated...


I see some discussion of adding aggregate functions on top of 
QgsExpression [1], which as I understand it, would make such functions 
available for use in the labelling dialog. I could then do something 
elegant like datetime = max(datetime) to select the most recent datapoint...


Regards

Gavin

[1] Towards the end of: 
https://groups.google.com/forum/#!topic/qgis-developer-remote/3pWsSyYSd9s


On 11/03/2014 5:35 a.m., Brent Wood wrote:

Hi Gavin,

Can you have the row written to two files concurrently? One as an 
append  one overwrite.
Both watched in QGIS  have the overwrite as the upper layer on the 
map with a different symbol, thus overwriting the trackline point in 
the append csv file.


Not as elegant as an SQL solution, but csv's are not really reknowned 
for their elegance in data management :-)



I haven't really thought this through, but you might try using a named 
pipe (see mkfifo on Linux, Windows has something along these lines 
too),  run tail -n 1 -f myfile.csv into the named pipe, then open 
this in QGIS. This is such a horrible solution it's almost certain not 
to work, but you never know :-)



Cheers,

   Brent

*From:* Gavin Macaulay ga...@macaulay.co.nz
*To:* qgis-user@lists.osgeo.org
*Sent:* Tuesday, March 11, 2014 9:18 AM
*Subject:* [Qgis-user] Labelling expressions: how to select the 'last' 
row in a csv dataset


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
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org mailto:Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user




___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

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

2014-03-10 Thread Basques, Bob (CI-StPaul)
Gavin,

Set up the CSV file creation to append to the top of the file instead of the 
bottom, then just read the first line for the special cartography.

If you are running on Linux, there are a whole bunch of options with AWK/GREP, 
etc to get the data outputting in a more favorable fashion for reading.

My first thought was to suggest the SQL path though, this gives you lots of 
options for archiving and looking at the path/trail over time . . .

I've just completed doing something similar for a AVL tracking system.

Bobb



-Original Message-
From: qgis-user-boun...@lists.osgeo.org 
[mailto:qgis-user-boun...@lists.osgeo.org] On Behalf Of Gavin Macaulay
Sent: Monday, March 10, 2014 3:18 PM
To: qgis-user@lists.osgeo.org
Subject: [Qgis-user] Labelling expressions: how to select the 'last' row in a 
csv dataset

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
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-03-10 Thread Brent Wood
Hi Gavin,

Can you have the row written to two files concurrently? One as an append  one 
overwrite.
Both watched in QGIS  have the overwrite as the upper layer on the map with a 
different symbol, thus overwriting the trackline point in the append csv file.

Not as elegant as an SQL solution, but csv's are not really reknowned for their 
elegance in data management :-)


I haven't really thought this through, but you might try using a named pipe 
(see mkfifo on Linux, Windows has something along these lines too),  run tail 
-n 1 -f myfile.csv into the named pipe, then open this in QGIS. This is such a 
horrible solution it's almost certain not to work, but you never know :-) 



Cheers,

   Brent



 From: Gavin Macaulay ga...@macaulay.co.nz
To: qgis-user@lists.osgeo.org 
Sent: Tuesday, March 11, 2014 9:18 AM
Subject: [Qgis-user] Labelling expressions: how to select the 'last' row in 
a csv dataset
 

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
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user