2

I would like to create bicycle router which routes more through shade. For that I would like to use OSM. Most routers use OSM xml so my question is:

How to add tags to a street that goes through a forest and write that back to OSM xml? Getting part of a street through forest is easy with POSTGIS. Some intersect operation probably. I can insert OSM to Postgresql with osm2psql but I have found no way to get it back in usable xml again.

My current idea is parsing OSM XML and saving forest polygons somewhere. Then in another pass intersect each road with a forest polygon if bounding boxes intersects. If road is fully in forest tag it as in_forest. If not split road and tag forest part as in forest and other part as is.

I would use python libraries (Shapely) or C++ if Python isn't fast enough. But this would probably take ages. My country is only 350MB unzipped OSM XML.

Is there any better way? I looked into osmosis tag-transform but this is only for regex changes.

3
  • Do you intend to upload the data in main server?
    – neogeomat
    Commented Jun 6, 2014 at 8:10
  • Routing is usually done with a Postgis database tuned for routing, so you could do the operation after loading the XML into your database.
    – AndreJ
    Commented Jun 6, 2014 at 8:25
  • No I don't intend to upload data. I don't think it would be usefull. I thought of using brouter or OTP.
    – MaBu
    Commented Jun 6, 2014 at 8:40

1 Answer 1

0

Your way of processing should be used for a prototype only because as you already know the OSM fileformat isn't tweaked for specific purposes but only an intermediate fileformat.

Usually you want to recycle an existing routing solution as pgrouting or graphhopper. Then you would like to extend the importers (osm2pgrouting or osm2po) to consider additional aspects for the routing graph, as shadow spending woods near the rail. How you can realize this step, depends on the specific project and might be an additional processing ("patching" the existing values) or could be implemented in the main import step.

P.S: You might consider smaller solutions as YOURS, Navit, or Brouter that give you first results very quickly and later change to pro solutions as pgrouting. Please also consider that OSM tagging hasn't a united tagging schema. So for analyzing shadows, you might be also interested in treelines, avenues or the height of buildings.

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.