[postgis-users] Making a line from points

Obe, Regina robe.dnd at cityofboston.gov
Wed Sep 19 06:20:57 PDT 2007


 
David,

Just to add to what Kevin said. Keep in mind makeline is an aggregate
sql function like any other.

If you wanted to add multiple line records to your bar table, you would
group by and order by a set of non-geom fields that is specific to your
lines. 

Something like.

INSERT INTO bar(the_geom, practice_name)
SELECT st_makeline(the_point) as the_route, bp.practice_name
FROM (SELECT the_point, practice_name
		FROM marathon_practice 
			ORDER BY practice_name, trip_datetime) bp 
GROUP BY bp.practice_name;


The above would give you a separate record for each practice run where
the points of each line are ordered by time.

If you are using the older versions of postgis, you may need to use
Makeline instead.  Makeline is for all intensive purposes deprecated
though in newer versions.

Hope that helps,
Regina




-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Kevin Neufeld
Sent: Wednesday, September 19, 2007 3:22 AM
To: dave.potts at pinan.co.uk; PostGIS Users Discussion
Subject: Re: [postgis-users] Making a line from points

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/00
6916.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
>   
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.




More information about the postgis-users mailing list