Skip to content

Instantly share code, notes, and snippets.

@martinnormark
Created March 18, 2014 00:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinnormark/9611287 to your computer and use it in GitHub Desktop.
Save martinnormark/9611287 to your computer and use it in GitHub Desktop.
Overpass query to get all roads inside a bounding box, that is either a tunnel or has some kind of bridge above.
<osm-script output="json" timeout="25">
<!-- Bridges -->
<query type="way">
<has-kv k="bridge" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="not" regv="." />
<bbox-query {{bbox}}/>
</query>
<!-- Find roads below the above bridges -->
<query type="way">
<around radius="0" />
<has-kv k="highway" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="." />
<has-kv k="maxheight:physical" modv="not" regv="." />
<has-kv k="tunnel" modv="not" regv="." />
</query>
<union>
<item />
<recurse type="way-node"/>
</union>
<!-- print results -->
<print mode="body"/>
<recurse type="down"/>
<print mode="skeleton" order="quadtile"/>
</osm-script>
<osm-script output="json" timeout="25">
<!-- Railway bridges -->
<query type="way">
<has-kv k="bridge" regv="^(yes|viaduct)$"/>
<has-kv k="railway" />
<bbox-query {{bbox}}/>
</query>
<!-- Find roads below the above railway bridges -->
<query type="way">
<around radius="0" />
<has-kv k="highway" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="." />
<has-kv k="maxheight:physical" modv="not" regv="." />
<has-kv k="tunnel" modv="not" regv="." />
</query>
<union>
<item />
<recurse type="way-node"/>
</union>
<!-- print results -->
<print mode="body"/>
<recurse type="down"/>
<print mode="skeleton" order="quadtile"/>
</osm-script>
@martinnormark
Copy link
Author

View the Railway bridges in Overpass Turbo.

View the Other bridges in Overpass Turbo.

@martinnormark
Copy link
Author

This seems to work Overpass Turbo

<osm-script output="json" timeout="20">
  <union into="_">
    <union into="_">
      <union into="_">
        <query into="_" type="way">
          <bbox-query {{bbox}}/>
          <has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
          <has-kv k="railway" modv="" v=""/>
        </query>
        <query into="_" type="way">
          <around from="_" into="_" lat="" lon="" radius="0"/>
          <has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
          <has-kv k="maxheight" modv="not" regv="."/>
          <has-kv k="maxheight:physical" modv="not" regv="."/>
          <has-kv k="tunnel" modv="not" regv="."/>
        </query>
      </union>
      <recurse from="_" into="_" type="down"/>
    </union>
    <union into="_">
      <union into="_">
        <query into="_" type="way">
          <bbox-query {{bbox}}/>
          <has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
          <has-kv k="railway" modv="" v=""/>
        </query>
        <query into="_" type="way">
          <around from="_" into="_" lat="" lon="" radius="0"/>
          <has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
          <has-kv k="maxheight" modv="not" regv="."/>
          <has-kv k="maxheight:physical" modv="not" regv="."/>
          <has-kv k="tunnel" modv="not" regv="."/>
        </query>
      </union>
      <recurse from="_" into="_" type="down"/>
    </union>
    <union into="_">
      <union into="_">
        <query into="_" type="way">
          <bbox-query {{bbox}}/>
          <has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
          <has-kv k="railway" modv="" v=""/>
        </query>
        <query into="_" type="way">
          <around from="_" into="_" lat="" lon="" radius="0"/>
          <has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
          <has-kv k="maxheight" modv="not" regv="."/>
          <has-kv k="maxheight:physical" modv="not" regv="."/>
          <has-kv k="tunnel" modv="not" regv="."/>
        </query>
      </union>
      <recurse from="_" into="_" type="down"/>
    </union>
    <union into="_">
      <union into="_">
        <query into="_" type="way">
          <bbox-query {{bbox}}/>
          <has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
          <has-kv k="railway" modv="" v=""/>
        </query>
        <query into="_" type="way">
          <around from="_" into="_" lat="" lon="" radius="0"/>
          <has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
          <has-kv k="maxheight" modv="not" regv="."/>
          <has-kv k="maxheight:physical" modv="not" regv="."/>
          <has-kv k="tunnel" modv="not" regv="."/>
        </query>
      </union>
      <recurse from="_" into="_" type="down"/>
    </union>
  </union>
  <print from="_" limit="" mode="body" order="id"/>
</osm-script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment