Can I use pgrouting (http://pgrouting.org/index.html) to change OSM data? My goal is to change the cost of some ways (increase and decrease) in order to change the routing calculation process. If possible, after edit, is it possible to save as a .osm file to use on NavIt?

Resume: Instead of create Tags inside of OSM data, I want to alter his graph structure. It's like a filter of the OSM original data.

Thanks for reading that ;-)

2 Answers 2


The original OSM data doesn't have weights. It has attributes (tags) like road class, maxspeed, width, surface and many more which can be used by tools like routing engines to calculate weights as a post-process step. Which of these attributes are actually used for weight calculation depends entirely on the specific router you are using. So the only valid options for artificially modifying weights is to either modify the routing engine or the exported data, but never the original data contained in the OSM database.

  • I'm not sure if you're totally right. If you use osm2pgrouting (pgrouting.org/docs/tools/osm2pgrouting.html) you will access all the OSM data, including length and costs. I think that if it's possible, the reverse is possible too.
    – user49521
    Aug 26, 2014 at 10:33
  • Pgrouting is for routing analysis. But it accesses the data from OSM maps. To access the data, it needs osm2pgrouting tool! I'm trying to import the data -> change -> export to .osm again...
    – user49521
    Aug 26, 2014 at 10:37
  • The reverse is not automatically possible because most routers calculate the weights based on more than one tag. On export you would have to store the calculated weight as a single tag and strip of all other tags because the original information isn't available any more. That could lead to the same weights again if doing another import, but depends on the specific router of course. But as far as I can see pgrouting only looks at the maxspeed tag. So you could give it a try if you manage to export the data again to a .osm file, which is the interesting part here.
    – scai
    Aug 26, 2014 at 11:20
  • As I saw on Pgrouting workshop, pgrouting have the following DB schema: id: int4 identifier of the edge source: int4 identifier of the source vertex target: int4 identifier of the target vertex cost: float8 value, of the edge traversal cost. A negative cost will prevent the edge from being inserted in the graph. Maybe it's possible to modify the cost and export.. I'll try, if it's successful I'll tell here or maybe I'll write a tutorial!
    – user49521
    Aug 26, 2014 at 11:50

If you want to edit OSM data with the goal of creating a new .osm file for Navit then have a look at this list of OSM editors: http://wiki.openstreetmap.org/wiki/Editing

PgRouting really is not the right tool for your use case.

  • this is not what I want because it does not allows me to change the graph's costs. From what I saw it only allows me to -> "Editing OpenStreetMap is the process of making changes to the map data - such as adding roads, pubs or changing names of features."
    – user49521
    Aug 25, 2014 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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