-2

How can I create a line, with Python functions, with many points that are records in PostGIS?

1 Answer 1

2

Not 100% what you are asking for, but why not creating the line in PostGIS first?

SELECT gps.gps_track, ST_MakeLine(gps.the_geom ORDER BY gps_time) As newgeom
FROM gps_points As gps
GROUP BY gps.gps_track;

That will create a different line for each gps track and order them by time. I use that to create bus routes, ordered by stop sequence.

Really fast too.

(from: http://postgis.net/docs/ST_MakeLine.htm)

3
  • Does not work, gives error in "order by" Commented May 9, 2013 at 16:46
  • Could you post your code? I'm not a PostGIS expert, I just happened to use that function 2-3 weeks ago, but it would help.
    – fgcarto
    Commented May 10, 2013 at 17:44
  • I used it to create line from shapes points from gtfs: CREATE TABLE cit.ligne_tr AS SELECT p.shape_id, ST_MakeLine(geom) As geom FROM (SELECT * FROM cit.shapes ORDER BY shape_pt_sequence) p GROUP BY p.shape_id;
    – fgcarto
    Commented May 10, 2013 at 18:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.