Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a project that requires finding the shortest path and to achieve this, I've used the PgRouting dijkstra function and it's all worked out perfectly.

Initially, the road network was imported using an osm file. The table created consists of multilinestring geometry types.

How can I transform the multilinestring into linestring and give each of them a source id and targer id so that dijkstra function gives the shortest path starting next to the point it has localised.

Thanks all !

share|improve this question

Don't do that. You better use tools like osm2pgrouting or osm2po to import OSM data for use with pgRouting.

To find the nearest start and end point you need to use PostGIS functions like "ST_Line_Locate_Point". You can write pl/pgsql wrapper functions to do this or your application can handle it.

share|improve this answer

Your Answer


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.