<div>As the subject suggests I need to create Linestrings by connecting Points.I have one table locations that looks like this:<br><br>CREATE TABLE locations<br>(<br>userid integer NOT NULL DEFAULT 0,<br>"time" integer NOT NULL DEFAULT 0,<br>
"timestamp" bigint,<br> the_geom geometry(Point,4326),<br>CONSTRAINT locations_pkey PRIMARY KEY (userid , "time" )<br>)<br><br>Basically it's a table with a lot of locations with Point geometries. Field 'time' is relative timestamp, from 0 to 179. So for every "userid" there is 180 entries with 180 locations.<br>
</div><div><br></div><div><br>What i need to do here is to create a new table which will have one Linestring per "userid", which was calculated from Points in locations table, of course in correct order defined in "time" attribute. So new table should look like this:<br>
<br>CREATE TABLE trajectories (<br> userid int NOT NULL default '0',<br> the_geom geometry(Linestring, 4326),<br>PRIMARY KEY ( userid )<br>)<br><br>I can't find a way to do that. Is it even possible to connect multiple points (in this problem 180 of them) to one Linestring with st_makeline? <br>
<br>I tried something like this<br></div><div><br></div><div>SELECT St_MakeLine(the_geom) as the_route, bp.userid<br>FROM (SELECT userid, the_geom, "time"<br> FROM locations<br> ORDER BY "time") bp <br>
GROUP BY bp.userid<br>
ORDER BY
bp.userid;<br></div><div><br></div><div>But result has geometries field empty...<br></div><div><br><br></div>