[postgis-users] Making links

Per-Olof Norén pelle at alma.nu
Wed Oct 24 04:35:57 PDT 2007


Hi,


Gustavo Ces skrev:
> Hi all,
>
>     I´ve got a railway linestring table and a railstation point table. Some linestring´s nodes are stations, and others aren´t. I have to extract a links table  from the linestring one,  with this structure
>
> link      StartStation     EndStation
>
> I´m trying to do it with ogr&python, but perhaps there is an easiest way to achive this in PostGis. Any help?
>
> Thanks in advance,
>
> Gus
>   

Given your description I assume you intend to split a larger (railway) 
linestring into smaller segments (the links) using the station table to 
mark each point as station?

You could possibly write a procedure in pl/pgsql using containing functions:

st_numpoints(geometry) - number of points in linestring
st_pointn(geometry) - extracs point from linestring
st_touches(geometry, geometry)  - check if points overlap (station and 
railwaypoint)


Hope this gives you some ideas, at least.

Regards,
Per-Olof



More information about the postgis-users mailing list