Search notes:

Overpass API

Querying an Overpass API endpoint

Python

The following snippet gives an idea how an Overpass API endpoint can be queried with Python:
import requests

query = """
[out:csv(::id,name)];
relation[admin_level="2"];
out;
"""

response = requests.get(
   'http://overpass-api.de/api/interpreter',
    headers = {'Accept-Charset': 'utf-8'},
    params  = {'data'          :  query }
)

response.encoding='utf-8'

with open('overpass-result.csv', 'w', encoding='utf-8') as file:
     file.write(response.text)
There is also the overpy library.

PowerShell

The following snippet gives an idea how an Overpass API endpoint can be queried with PowerShell:
$query = @'

  [out:json];
  nwr [name=Freienstein];
  out;

'@

$res     = invoke-webRequest -method post -body (@{'data' = $query}) https://overpass-api.de/api/interpreter
$resTxt  = $res.Content
$resJson = convertFrom-json $resTxt

foreach($elem in $resJson.elements) {
   "id: $($elem.id) ($($elem.type))"

   if ($elem.type -eq 'node') {
      "  $($elem.lat) $($elem.lon)"
   }

   …
}

File extension

The proposed file extension for files that store Overpass API queries is *.overpassql.

TODO

Calculating distances

Although there is a length() function, the calculation of distances (notably between two nodes) seems impossible.

Find buildings whose house number is 13

{{geocodeArea:Pfungen}};              // Search in Pfungen

nw                                    // Search nodes and ways
  [building]                          // that have a building and
  ['addr:housenumber']                // an addr:housenumber tag.
  (area)                              // Restrict search to selected area (geocodeArea)
  (if: t['addr:housenumber'] == 13 ); // and keep only those objects whose addr:housenumber value is 13

out geom;

olbricht.nrw/ovt

olbricht.nrw/ovt is a temporary instance of Overpass Turbo (and seems to have an implementation that translates osm to GeoJSON).
The source code is hosted on github (osmtogeojson)

See also

Overpass language constructs such as
Some Overpass API queries
The R package osmplotr creates visually impressive customisable images of OpenStreetMap data downloaded internally via the Overpass API.
Overpass Turbo IDE extensions for the Overpass API
Making Overpass-API requests from a webpage

Index