Take the 2-minute tour ×
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

closed as unclear what you're asking by PolyGeo, Fezter, Aaron, whuber Jul 24 '13 at 2:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

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)

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

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