<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"Préformaté HTML Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Texte de bulles Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;}
span.PrformatHTMLCar
        {mso-style-name:"Préformaté HTML Car";
        mso-style-priority:99;
        mso-style-link:"Préformaté HTML";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.TextedebullesCar
        {mso-style-name:"Texte de bulles Car";
        mso-style-priority:99;
        mso-style-link:"Texte de bulles";
        font-family:"Tahoma","sans-serif";
        color:black;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I may be wrong, but with this method, I’m afraid you will have the same start and end time for each vehicle and status (the start time of the first line and le end time of the last one by vehicle and status) instead of a unique start / end time for each line.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>To have the start and end for each line, I think you will have to retrieve them in a second time comparing start and end point of each line with the original gps points. Another solution would be to create a plpgsql function to build the linestring from a loop.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hugues.</span><span lang=EN-GB style='font-size:13.5pt'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> postgis-users-bounces@lists.osgeo.org [mailto:postgis-users-bounces@lists.osgeo.org] <b>De la part de</b> Roxanne Reid-Bennett<br><b>Envoyé :</b> mardi 25 novembre 2014 19:17<br><b>À :</b> postgis-users@lists.osgeo.org<br><b>Objet :</b> Re: [postgis-users] Creating trajectory/lines from millions ofpoints[PostGIS]<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On 11/25/2014 11:48 AM, Oliver Burgfeld wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal style='margin-bottom:12.0pt'>I also tried that and it works but it does not give me those two columns in my new table. There are only id and status inside.<o:p></o:p></p></div></blockquote><p class=MsoNormal>From the quer below change<br><span lang=EN-GB style='font-size:11.0pt'>SELECT id, status, (ST_Dump(mylines)).geom<br>to <br></span><br><span lang=EN-GB style='font-size:11.0pt'>SELECT id, status, (ST_Dump(mylines)).geom, time_start, time_end<br><br>Something to keep an eye out for... Depending upon your version of PostGIS and the underlying libraries, because we were working with an older version of the underlying libraries, I don't know if this is still a potential issue.  We ran into issues with "stacked" points (2 GPS points with the same coordinates), and GPS drift causing issues with the linestrings being pretty goofy (jagged points in the linestring that were clearly NOT what the vehicle did).    We wrote cleanup scripts to take care of those issues (that are still in place).  I've not taken time to revisit the library routines to see if they now handle those conditions cleanly.<br><br>Roxanne<br><br><br></span><o:p></o:p></p><div><p class=MsoNormal> <br>Am Dienstag, 25. November 2014 17:39:21 UTC+1 schrieb Brent Wood: <o:p></o:p></p><div><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>as in my previous reply, I figured that would be useful...<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>WITH multis AS (</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                SELECT id, status,<b> min(timestamp) as time_start, max(timestamp) as time_end, </b>ST_MakeLine( point_geom ORDER BY timestamp) AS mylines</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                FROM your_table</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>GROUP BY id, status</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>)</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>SELECT id, status, (ST_Dump(mylines)).geom</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>FROM multis</span><span style='font-family:"Helvetica","sans-serif"'>Brent Wood<o:p></o:p></span></p><div><div><div><div class=MsoNormal align=center style='text-align:center;background:white'><span style='font-family:"Helvetica","sans-serif"'><hr size=1 width="100%" align=center></span></div><p class=MsoNormal style='background:white'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> Oliver Burgfeld <<a href="javascript:" target="_blank">oliver....@gmail.com</a>><br><b>To:</b> <a href="javascript:" target="_blank">postgi...@googlegroups.com</a> <br><b>Cc:</b> <a href="javascript:" target="_blank">pcr...@pcreso.com</a>; <a href="javascript:" target="_blank">postgi...@lists.osgeo.org</a>; <a href="javascript:" target="_blank">postgi...@lists.osgeo.org</a>; <a href="javascript:" target="_blank">remi...@gmail.com</a> <br><b>Sent:</b> Wednesday, November 26, 2014 5:10 AM<br><b>Subject:</b> Re: [postgis-users] Creating trajectory/lines from millions of points[PostGIS]</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p><div><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>Thank you and all the others who were answering :)<br><br>I tried that and it seems that its working. Nevertheless I only tried it with a small part of my data (round about 1 million rows out of ~500 million) but if it's working now, it should also work with the whole dataset.<br><br>Is there a way to also include the time_field into the result? I created a new table with this statement given but there are only two columns (vehicleid and status) included. <br>I know thats logical because I only included those two into my select clause but it would be great to not only order by time but also have a time column in my table.<br><br>For example:<br><br>vehicleid | status | time_start | time_end<br><br><br>I hope its understandable and not to mixed up...<br><br>Thanks!<br><br><br>Am Dienstag, 25. November 2014 16:06:33 UTC+1 schrieb Rémi Cura: <o:p></o:p></span></p><div><div><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>Hey, a small correction :<o:p></o:p></span></p></div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>ST_MakeLine is already an aggregate, and you may want to enforce the order inside the aggregate (see at the end).<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>Another interesting point is the possiblity to pu somehting in the M value of each point of the line, for instance the time.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>This comes very handy when you want to extrat parts of the lines.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><p class=MsoNormal style='margin-bottom:12.0pt;background:white'><span style='font-family:"Helvetica","sans-serif"'>So for instance for the first proposition :<o:p></o:p></span></p><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>WITH multis AS (</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                SELECT id, status,<b> ST_MakeLine( point_geom ORDER BY time_field) </b>AS mylines</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                FROM your_table</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>GROUP BY id, status</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>)</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>SELECT id, status, (ST_Dump(mylines)).geom</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><p class=MsoNormal style='margin-bottom:12.0pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>FROM multis</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>Cheers,<br>Rémi-c<o:p></o:p></span></p><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div></div></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>2014-11-25 9:53 GMT+01:00 Brent Wood <<a href="mailto:pcr...@pcreso.com">pcr...@pcreso.com</a>>:<o:p></o:p></span></p><div><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>or automatically get the start & end times for each trackline in the record like this:<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>WITH multis AS (</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                SELECT id, min(time_field) AS time_start, max(time_field) as time_end, status, ST_MakeLine(array_agg(point_ geom )) AS mylines</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                FROM your_table</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>GROUP BY id, status</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>ORDER BY time_field</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>)</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>SELECT id, status, (ST_Dump(mylines)).geom</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>FROM multis;</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>Cheers,</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>   Brent Wood</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><div><div><div class=MsoNormal align=center style='text-align:center;background:white'><span style='font-family:"Helvetica","sans-serif"'><hr size=1 width="100%" align=center></span></div><p class=MsoNormal style='background:white'><b><span style='font-family:"Arial","sans-serif"'>From:</span></b><span style='font-family:"Arial","sans-serif"'> Hugues François <<a href="mailto:hugues....@irstea.fr">hugues....@irstea.fr</a>><br><b>To:</b> PostGIS Users Discussion <<a href="mailto:postgi...@lists.osgeo.org%20">postgi...@lists.osgeo.org </a>> <br><b>Sent:</b> Tuesday, November 25, 2014 8:13 PM<br><b>Subject:</b> Re: [postgis-users] Creating trajectory/lines from millions of points[PostGIS]</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p><div><div><div><div><p class=MsoNormal style='background:white'><span style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>Hello,</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>In your case I would have try to make multilines for each taxi and each status (i.e. two multi by taxi) and then dump them into  simple linestrings. All in a query that may look like this assuming you have a taxi id field:</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>WITH multis AS (</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                SELECT id, status, ST_MakeLine(array_agg(point_ geom )) AS mylines</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>                FROM your_table</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>GROUP BY id, status</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>ORDER BY time_field</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>)</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>SELECT id, status, (ST_Dump(mylines)).geom</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>FROM multis</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>You may want to add a time reference to your lines. To do this, you can add an extraction from your timestamp field (e.g. day or month) and add it into the WITH and to the group by clause.</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>Hugues.</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:35.4pt;background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'> </span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><b><span style='font-size:10.0pt;font-family:"Helvetica","sans-serif"'>De :</span></b><span style='font-size:10.0pt;font-family:"Helvetica","sans-serif"'> <a href="mailto:postgis-us...@lists">postgis-us...@lists</a>. osgeo.org [mailto:postgis-us...@ lists.osgeo.org] <b>De la part de</b> Oliver Burgfeld<br><b>Envoyé :</b> mardi 25 novembre 2014 07:09<br><b>À :</b> <a href="mailto:postgi...@lists.osgeo.org">postgi...@lists.osgeo.org</a><br><b>Objet :</b> [postgis-users] Creating trajectory/lines from millions of points[PostGIS]</span><span style='font-family:"Helvetica","sans-serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt;background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><div><div><div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>Hi,<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>I have millions of points in a PostGIS database containing taxi gps tracks. Now I want to create lines from these points by vehicleid and ordered by timestamp. But, and that's my problem right now, at first I want to include every column of my point table into the "line table" and I also need to intersect those lines at specific points.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>I have one column representing the "taxi_is_occupied" status with 0 or 1. <o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>What I want now is to create lines which are divided every time this status changes. In the end I need lines which show the path of every taxi over time, divided every time the status of the car changes so that I can query all lines where the taxi is occupied, for example.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>What do I have to use therefore? I know that there is the ST_MakeLines tool existing in PostGIS, but as I am a new PostGIS user... I do not know exactly how to use it to get the results I need. <o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>Thanks a lot<o:p></o:p></span></p></div></div></div></div></div></div></div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'>______________________________ _________________<br>postgis-users mailing list<br><a href="mailto:postgi...@lists.osgeo.org">postgi...@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi- bin/mailman/listinfo/postgis- users</a><o:p></o:p></span></p></div><p class=MsoNormal style='margin-bottom:12.0pt;background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div></div></div></div></div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><br>______________________________ _________________<br>postgis-users mailing list<br><a href="mailto:postgi...@lists.osgeo.org">postgi...@lists.osgeo.org</a> <o:p></o:p></span></p><div><p class=MsoNormal style='margin-bottom:12.0pt;background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi- bin/mailman/listinfo/postgis- users</a><o:p></o:p></span></p></div></div><div><p class=MsoNormal style='background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div></div></div></div></div><p class=MsoNormal style='margin-bottom:12.0pt;background:white'><span style='font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p></div></div></div></div></div></div><p class=MsoNormal><br><br><br><o:p></o:p></p><pre>_______________________________________________<o:p></o:p></pre><pre>postgis-users mailing list<o:p></o:p></pre><pre><a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><o:p></o:p></pre><pre><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><o:p></o:p></pre><p class=MsoNormal><br><br><br><o:p></o:p></p><pre>-- <o:p></o:p></pre><pre>[At other schools] I think the most common fault in general is to teach students how to pass exams instead of teaching them the science.<o:p></o:p></pre><pre>Donald Knuth<o:p></o:p></pre></div></body></html>