Tuesday 5 April 2016

postgis - How to generate pgrouting source and target with OSM?


I'm wondering how to generate with the given lonlat in OSM PostGIS entities.


In pgrouting's website, they are telling that source and target are identifier of the vertex but not telling if this an osm_id for OSM database or any. My only given to generate is lonlat of the potential source/target. I'm using osm2po to create routable database.


Can anyone give me a clue, so that I can make my map more dynamic?



Answer



In case you haven't tried it yet, the pgRouting Workshop is always a good place to get started.


When you used osm2po to convert your OSM data, then source and target attributes are already there and ready to use.



Sometimes the vertices table, that contains all source and target ID's, is useful to find the nearest vertex from a geographic point. The osm2po SQL file does not contain this table, but there is a function to create it:


SELECT pgr_createVerticesTable('','geom_way','source','target');

To find the nearest node is now a simple PostGIS query.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...