Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question

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.

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

share|improve this answer
Does not work, gives error in "order by" – user1573901 May 9 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. – fgcartographix May 10 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; – fgcartographix May 10 at 18:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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