I have oriented polylines (Montreal's train network) and stops (train stations).

My network looks like this: Train Network

(closer look): Train stations

I'd like to split my tracks at each stations and ideally add fields FromStation, ToStation to my new Train tracks table.

I've used ST_Snap to snap my points to my tracks so there's an intersection. There's no guaranty though that there's a node where it intersects.

I tried some variation using ST_Split. No error, but no results either. Just empty geometry in the end.

My data comes from the gtfs, so for now, I have a shape_id, trip_headsign and route_short_name on each line.

If I could have a resulting table like

shape_id fromstation tostation
2_1      VRM1B       SLR3B
2_1      SLR3B       SLR2B
2_1      SLR2B       SLR1B

(shape_id 2_1 is the blue line west bound), that would be ideal.

I need somehow to use that to create a personnel allocation model for our inspectors and agents on the network. Each segments will be considered a road in Network Analyst with usage restriction to match the train schedule at each train station... Never found anything like that done, but I've been given the task to at least try.

  • postgis.net/docs/ST_Split.html see SELECT ST_AsText(ST_Split(mline, pt)) As wktcut if not make polygons from your points with ST_buffer then split
    – Mapperz
    Apr 2, 2014 at 16:22

1 Answer 1


You might need to use the linear referencing functions to get what you want. For each point, use ST_LineLocatePoint to find out what proportion along the line the point is, then for each pairing of points, use ST_LocateBetween to extract the portion of the line between the points. So rather than splitting, you're using linear referencing to extract.


  • Good tips from the Master... I'll try that, thanks!! :)
    – fgcarto
    Apr 2, 2014 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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