Postpass/Overpass QL

From OpenStreetMap Wiki
Jump to navigation Jump to search

a pen and a ruler laying across each other

This page is a work in progress! The content is likely incomplete, inaccurate or empty.

This article lists equivalent syntax to convert between Postpass and Overpass: Overpass_API/Overpass QL

Users new to either PostGIS/PostgreSQL/SQL or Overpass can refer to the other side they are more familiar with. It's also useful for copying code snippets without saving queries.

To-do: Make side-by-side table similar to Template:OverpassTurboRosetta (But page creator thinks using split view in browser may be more convenient)

Lanugage overview

Settings

timeout:

Element limit (maxsize:)

Output format (out:)

CSV output mode

This Unix command line will create a count of various amenity types in a fixed bounding box, and output the result as a CSV file with the help of the general-purpose JSON conversion utility "jq".

curl -g https://postpass.geofabrik.de/api/0.2/interpreter \
    --data-urlencode "options[geojson]=false" --data-urlencode "data=
      SELECT count(*), tags->>'amenity' as amenity
      FROM postpass_point
      WHERE tags?'amenity'
      AND geom && st_makeenvelope(8.34,48.97,8.46,49.03,4326)
      GROUP BY amenity" |
jq -r '["amenity","count"], (.result[] | [ .amenity, .count ]) | @csv' > myfile.csv

Global bounding box (bbox)

Not available

Date

Not available

Difference between two dates (diff)

Not available

Augmented-difference between two dates (adiff)

Not available

Block statements

Standalone statements

out

  • Verbosity
    • out ids : SELECT string_agg(LOWER(osm_type) || osm_id::text,',') (format to download objects in JOSM)
  • Modificators for geolocated information
    • geom : Default by including geom in SELECT
    • bb :
    • center
      • ST_Centroid(geom) : Closest to original in Overpass
      • ST_PointOnSurface(geom) : Carto method
      • (ST_MaximumInscribedCircle(geom)).center : More precise
  • Bounding box
  • Sort order
    • ORDER BY tags->>'name' ASC : Sort by tag in ascending order(ASC is default)
    • ORDER BY osm_type ASC, osm_id DESC : Collects same object type, then sorts by newest (descending order)
    • ORDER BY osm_type ASC, tags->>'amenity' ASC : They can be combined
  • Limits the output: LIMIT 12

Item

Filters

By tag (has-kv)

Equals (=, !=)

Equals

tags->>'name'='Foo'

Not equals

tags->>'name'!='Foo'

Exists

Single

tags?'name'

Any of them

tags?|array['name:es','name:fr']

All of them

tags?&array['name','name:en']

Not exists

NOT tags?'name'

Value matches regular expression (~, !~)

Case insensitively

Key/value matches regular expression (~"key regex"~"value regex")

Bounding box

geom && ST_MakeEnvelope(south,west,north,east, 4326)
geom && ST_MakeEnvelope(50.6,7.0,50.8,7.3, 4326)

Recurse (n, w, r, bn, bw, br)

See also