Overpass Ultra/Extensions

From OpenStreetMap Wiki
Jump to navigation Jump to search
Overpass API logo.svg
edit
Overpass API · Language reference · Language guide · Technical terms · Areas · Query examples · Sparse Editing · Permanent ID · FAQ · more · Web site
Servers status · Versions · Development · Technical design · Installation · XAPI compatibility layer · Public transport sketch lines · Applications · Source code and issues
Overpass turbo · Wizard · Overpass turbo shortcuts · MapCSS stylesheets · Export to GeoJSON · more · Development · Source code and issues · Web site
Overpass Ultra · Overpass Ultra extensions · MapLibre stylesheets ·more · Source code and issues · Web site

Overpass Ultra uses an extended Overpass queries in several cases: this provides handy shortcuts for frequently used pieces of code like the {{bbox}} of the map. There also exist extensions to allow additional data and/or settings to be provided for each query, like a MapLibre style for example.

These extensions are specific to the Overpass Ultra interface and take precedence over the Overpass QL syntax (i.e. they are evaluated directly in the browser and not sent to the Overpass API). Settings are included as YAML front-matter before a query and shortcuts are written inline in any overpass query, delimited from it by double curly braces (beginning with {{ and ending with its counterpart }}).

Here you can find detailed examples of overpass turbo queries: Overpass API/Overpass API by Example - OpenStreetMap Wiki

Available Shortcuts

shortcut description replaced with
{{bbox}} Is replaced with the bounding box coordinates of the current map view-port. 48…,16…,49…,17…

Available YAML front-matter keys

key description example
style:… Specifies a MapLibre style. See this subpage for more info. style: https://example.com/style.json
server:… Allows to specify an Overpass API server. . server: http://overpass-api.de/api/
popupTemplate:… Specify the template to render in the interactive popup using LiquidJS. Can also be set to false to disable the popup. . popupTemplate: "{{type}} {{id}} - {{tags.name}}"


Example query using shortcut & YAML front-matter settings

---
server: https://overpass-api.de/api/
style: https://styles.trailsta.sh/openmaptiles-osm.json
---
node[amenity=drinking_water]({{bbox}});
out geom;

Load query in Overpass Ultra Load query in Overpass Ultra


OpenHistoricalMap example

This example configures the overpass query to be used with OpenHistoricalMap

---
server: https://overpass-api.openhistoricalmap.org/api/
style: https://openhistoricalmap.github.io/map-styles/ohm_timeslider_tegola/tegola-ohm.json
popupTemplate: >
  <h2>
    {{type}}
    <a href="https://openhistoricalmap.org/{{type}}/{{id}}" target="_blank">{{id}}</a>
    <a href="https://openhistoricalmap.org/edit?{{type}}={{id}}" target="_blank">✏️</a>
  </h2>
  {%- for tag in tags %}
    <code>{{tag[0]}} = {{tag[1]}}</code>
    <br>
  {%- endfor%}
---

Load query in Overpass Ultra Load query in Overpass Ultra


hub.toolforge.org example

This example configures the popupTemplate to display an image for emergency=sirens using model:wikidata=*, siren:model:wikidata=*, and https://hub.toolforge.org

---
popupTemplate: >
  {% assign wikidata = tags["siren:model:wikidata"] ?? tags["model:wikidata"] %}
  {%- if wikidata %}
  <img src="https://hub.toolforge.org/{{ wikidata }}?p=image&w=200&h=150">
  {%- endif %}
---

[bbox:{{bbox}}];

node["emergency"="siren"][~"^(siren:)?model:wikidata$"~".*"];

out geom;

Load query in Overpass Ultra Load query in Overpass Ultra