Overpass API: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
K
K
 
(72 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
Overpass API - Selektiver Download von Daten aus der Hauptdatenbank von [[OpenStreetMap]].
+
'''Overpass API - Gefilterter Download von [[OpenStreetMap]]-Daten in der nativen Struktur Nodes, Ways, Relations.'''
  
Siehe auch [[HowTo OpenStreetMap]]
+
Overpass Turbo Services (interaktive Webapp): '''>> Weltweit: http://overpass-turbo.eu/ <<''', Schweiz: http://overpass-turbo.osm.ch/ , Deutschland: http://overpass-api.de/
  
Webseiten:  
+
Overpass QL Query Beispiele:  
* Overpass API (Dokumentation und öff. Server): http://overpass-api.de/ und http://wiki.openstreetmap.org/wiki/Overpass_API
+
* >> '''[[Overpass QL Beispiele]]''' <<
* Overpass Turbo (Webapp/Server): http://overpass-turbo.eu/
+
* Overpass API by Example: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example
 +
* https://osm-queries.ldodds.com/for-local-mappers/index.html
  
Beispiel 1: Siehe [[Nutzen von OpenStreetMap-Daten in GIS]].
+
Prompt für '''>> ChatGPT & Co. <<''' (Copy & Paste und ersetze "user query"):
  
Beispiel 2: Alle Eisenbahnschienen in der Gegend von Rapperswil
+
<pre>
 +
Convert the following natural language query into valid Overpass QL syntax for use on [Overpass Turbo](https://overpass-turbo.eu/):
  
Diskussion:
+
**Natural Language Query:**
* Die BBox-Werte für Osten müssen größer sein als für Westen und genauso die Werte für Norden größer als für Süden. Also: s<n und w<e, sortiert als s,w,n,e (Rapperswil: 47.213,8.704,47.336,8.905).
+
<<Insert user query here>>.
* '<nowiki>{{bbox}}</nowiki>' ist eine Variable im Overpass Turbo (funktioniert im Overpass Service natürlich nicht).
 
* 'recurse' löst Referenzen von Ways zu Nodes auf (warum auch immer 'recurse' (und nicht z.B. dereference) da dies ja nur einstufig ist?)
 
* 'union' fasst Ergebnismengen von Anfragen zusammen - auch wenn's im Falle von recurse nur eine ist (...?) (OR-Verknüpfung)
 
* 'print' gibt die Sache aus (warum auch immer print gewählt wurde, da dies ja nichts mit der Konsole zu tun hat... Warum nicht 'format='?)
 
  
XML:
+
**Requirements:**
  <osm-script timeout="900">
+
1. The generated Overpass QL query must adhere to this [EBNF specification](https://gist.githubusercontent.com/sfkeller/43800cd64014d17c55e40fa5e877fd6a/raw/3410bd8817e47c86e5695388a96ba1db5c0630a7/Overpass_QL_EBNF_v0.2_ChatGPT_generated.txt).
    <union>
+
2. Ensure the use of appropriate tags (with both key and value) sourced from the [OpenStreetMap Wiki](https://wiki.openstreetmap.org/wiki/DE:How_to_map_a) and from [Beautified JOSM presets](https://raw.githubusercontent.com/simonpoole/beautified-JOSM-preset/master/master_preset.xml) to align with the user's intent.
      <query type="way">
+
3. Prefer geocoding with `geocodeArea` for region-specific queries rather than `area["name"=...]` unless unless a relation, an OSM Id or a geographic wikidata item is given.
        <has-kv k="railway" v="rail"/>
+
4. Use `nwr` to cover nodes, ways and relations, unless the query requires distinct nodes, ways, or relations.
        <bbox-query {{bbox}}/>
+
5. Prefer JSON output with `out center` (center coordinates) over `out geom` unless there are no nodes involved.
      </query>
+
</pre>
      <recurse type="way-node"/>
 
      <query type="way">
 
        <has-kv k="railway" v="narrow_gauge"/>
 
        <bbox-query {{bbox}}/>
 
      </query>
 
      <recurse type="way-node"/>
 
    </union>
 
    <print/>
 
  </osm-script>
 
  
QL:
+
* Beispiele für erfolgreiche "user queries":
  [timeout:900];
+
** All restaurants including fast_food in Rapperswil-Jona
  (
+
** All bars around 3000 meters from the adress "Bahnhof Rapperswil-Jona"
    way
+
** All restaurants within 3000 meters of a public stop in of Switzerland
      ["railway"="rail"]
+
** All restaurants in Kanton Glarus within 200 meters of public transport stops (station, bus_stop, tram_stop, funicular)
      (47.213,8.704,47.336,8.905);
 
    node(w);
 
  );
 
  out;
 
  
Kompakte QL:
+
* Beispiele für nicht erfolgreiche "user queries": Mountain passes of Switzerland which are navigable with a lake nearby" - siehe [[Overpass QL Beispiele]].
* <nowiki>http://www.overpass-api.de/api/interpreter?data=(way["railway"="rail"](47.213,8.704,47.336,8.905);node(w););out;</nowiki>
 
* http://www.overpass-api.de/api/interpreter?data=(way%5B%22railway%22%3D%22rail%22%5D(47.213%2C8.704%2C47.336%2C8.905)%3Bnode(w)%3B)%3Bout%3B%0A
 
  
Alternative: XML mit Regex:
+
Einstieg in Overpass QL und API:
 +
* >> '''"Offizielles" Handbuch zur Overpass API: https://dev.overpass-api.de/overpass-doc/de/ <<'''
 +
* "Learn Overpass": http://osmlab.github.io/learnoverpass//en/
 +
* Getting Started with Overpass Turbo (2020): https://nixintel.info/osint-tools/getting-started-with-overpass-turbo-part-1/
 +
* Tutorial: https://osm-queries.ldodds.com/tutorial/index.html
 +
* Blog: https://dev.overpass-api.de/blog/
  
  <osm-script timeout="900">
+
Overpass QL Language Documentation:
    <union>
+
* http://wiki.osm.org/wiki/Overpass_API
      <query type="way">
+
* https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL
        <has-kv k="railway" regv="^(rail|narrow_gauge)$"/>
+
* https://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide
        <bbox-query s="47.213" w="8.704" n="47.336" e="8.905"/>
+
* [[Overpass API EBNF]] (experimental)
      </query>
 
      <recurse type="way-node"/>
 
    </union>
 
    <print/>
 
  </osm-script>
 
  
XML mit Negation und Regex:
+
Support:
 +
* Mailing list: http://listes.openstreetmap.fr/wws/info/overpass
 +
* https://help.openstreetmap.org/questions/20479/using-osm-data-with-javascript-via-api-in-my-code-display-data-as-text
  
  <osm-script timeout="900">
+
Siehe auch:
    <union>
+
* [[OSM-Technisches]]
      <query type="way">
+
* [[HowTo OpenStreetMap]]
        <has-kv k="railway" modv="not" regv="rail|narrow_gauge"/>
+
* [https://stackoverflow.com/questions/tagged/overpass-api Stackoverflow 'overpass-api']
        <bbox-query s="47.213" w="8.704" n="47.336" e="8.905"/>
 
      </query>
 
      <recurse type="way-node"/>
 
    </union>
 
    <print/>
 
  </osm-script>
 
  
[[Kategorie:Howto]] [[Kategorie:OpenStreetMap]]
+
[[Kategorie:Howto]]  
 +
[[Kategorie:OpenStreetMap]]
 +
[[Kategorie:Overpass]]

Aktuelle Version vom 22. September 2024, 22:40 Uhr

Overpass API - Gefilterter Download von OpenStreetMap-Daten in der nativen Struktur Nodes, Ways, Relations.

Overpass Turbo Services (interaktive Webapp): >> Weltweit: http://overpass-turbo.eu/ <<, Schweiz: http://overpass-turbo.osm.ch/ , Deutschland: http://overpass-api.de/

Overpass QL Query Beispiele:

Prompt für >> ChatGPT & Co. << (Copy & Paste und ersetze "user query"):

Convert the following natural language query into valid Overpass QL syntax for use on [Overpass Turbo](https://overpass-turbo.eu/):

**Natural Language Query:**
<<Insert user query here>>.

**Requirements:**
1. The generated Overpass QL query must adhere to this [EBNF specification](https://gist.githubusercontent.com/sfkeller/43800cd64014d17c55e40fa5e877fd6a/raw/3410bd8817e47c86e5695388a96ba1db5c0630a7/Overpass_QL_EBNF_v0.2_ChatGPT_generated.txt).
2. Ensure the use of appropriate tags (with both key and value) sourced from the [OpenStreetMap Wiki](https://wiki.openstreetmap.org/wiki/DE:How_to_map_a) and from [Beautified JOSM presets](https://raw.githubusercontent.com/simonpoole/beautified-JOSM-preset/master/master_preset.xml) to align with the user's intent.
3. Prefer geocoding with `geocodeArea` for region-specific queries rather than `area["name"=...]` unless unless a relation, an OSM Id or a geographic wikidata item is given.
4. Use `nwr` to cover nodes, ways and relations, unless the query requires distinct nodes, ways, or relations.
5. Prefer JSON output with `out center` (center coordinates) over `out geom` unless there are no nodes involved.
  • Beispiele für erfolgreiche "user queries":
    • All restaurants including fast_food in Rapperswil-Jona
    • All bars around 3000 meters from the adress "Bahnhof Rapperswil-Jona"
    • All restaurants within 3000 meters of a public stop in of Switzerland
    • All restaurants in Kanton Glarus within 200 meters of public transport stops (station, bus_stop, tram_stop, funicular)
  • Beispiele für nicht erfolgreiche "user queries": Mountain passes of Switzerland which are navigable with a lake nearby" - siehe Overpass QL Beispiele.

Einstieg in Overpass QL und API:

Overpass QL Language Documentation:

Support:

Siehe auch: