How can I create a line, with Python functions, with many points that are records in PostGIS?
1 Answer
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.
-
-
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.– fgcartoCommented 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;– fgcartoCommented May 10, 2013 at 18:14