OpenStreetMap pbf files- extracts all street/roads intersections in a bounding box

315 Views Asked by At

I wrote a query which extracts all street/roads intersections in a bounding box from OpenStreetMaps, as can be seen here:

    <osm-script>
<query type="way" into="hw">
  <has-kv k="highway"/>
  <has-kv k="highway" modv="not" regv="footway|cycleway|path|service|track"/>
   <bbox-query e="51.0" n="50.748" s="50.746" w="7.154"/> 
</query>
 
<foreach from="hw" into="w">
  <recurse from="w" type="way-node" into="ns"/>
  <recurse from="ns" type="node-way" into="w2"/>
  <query type="way" into="w2">
    <item set="w2"/>
    <has-kv k="highway"/>
    <has-kv k="highway" modv="not" regv="footway|cycleway|path|service|track"/>
  </query>
  <difference into="wd">
    <item set="w2"/>
    <item set="w"/>
  </difference>
  <recurse from="wd" type="way-node" into="n2"/>
  <recurse from="w"  type="way-node" into="n3"/>
  <query type="node">
    <item set="n2"/>
    <item set="n3"/>
  </query>
  <print/>
</foreach>
  </osm-script>

However, i want to work locally on pbf files so i need to figure out how to do it. is it possible to extract all street/roads intersections in a bounding box using OSMFILTER/OSMCONVERT/Osmosis/OTHER?

Thanks guys.

1

There are 1 best solutions below

0
On

If you are ok with using Java, you can try Atlas: https://github.com/osmlab/atlas

It reads osm PBF files, and cuts all navigable ways at intersections. Then all the network Node objects are the intersections you are looking for.