[postgis-users] Making a line from points

Kevin Neufeld kneufeld at refractions.net
Wed Sep 19 00:21:52 PDT 2007


INSERT INTO bar
  SELECT ST_Makeline(the_geom)
  FROM (SELECT the_geom FROM foo ORDER BY some_ordering_attribute) AS 
my_sub_query;

The reason for the subquery is to order your points based on some 
attribute ... like a timestamp.

Those ordered points are then passed to your makeline function call.

Hope this clarifies things.
-- Kevin

-------------
Kevin Neufeld
Software Developer
Refractions Research Inc.
300-1207 Douglas St.
Victoria, B.C., V8W 2E7

Phone: (250) 383-3022
Email: kneufeld at refractions.net



David Potts wrote:
> hi List,
>
> I am trying to make a linestring from a serries of points,  I have tried
> things like
>
> update linetable set the_geom=makeline(select the_geom from points_table);
>
> witch did'nt work, having looked at the documentation for making making
> linestrings (addpoint,makeline, etc) and seen a previous example from
> (http://postgis.refractions.net/pipermail/postgis-users/2005-February/006916.html)
>
> SELECT MakeLine(the_geom) FROM ( SELECT the_geom FROM points
> 	ORDER BY time ) foo;
> I am still confused,  I can't see how the last example is designed to work!
>
>
> So if I have table called bar with an empty linestring geometry column and
> I have another table foo with a series of valid point geometry entires,
> how do I populate bar from foo?
> David
>   



More information about the postgis-users mailing list