Skip to content

Overpass: Out Syntax

Ramya edited this page Dec 30, 2016 · 3 revisions

Out statements in Query Language

In general out; or out body; in a query, generates features/elements for that query with associated ids, tags, relation members & its roles, and geometries. However all these are produced without any meta information. Here's an example query.

Additional parameters can be supplied to this default statement, to control the verbosity & order of the result generated.

Verbosity of out statements

Overpass Statements What does it return? Example query
out ids; Returns only id of output elements http://overpass-turbo.eu/s/kVU
out skel; Returns geometry information of elements, but ignores tags http://overpass-turbo.eu/s/kVW
out tags; Returns id + tags, but no geometry is specified http://overpass-turbo.eu/s/kVY
out geom; Complete geometry of all features + id & tags without any meta information http://overpass-turbo.eu/s/kVZ
out geom(minlat, minlong, maxlat, maxlong); Complete geometry of all features within (minlat, minlong, maxlat, maxlong) + id & tags without any meta information http://overpass-turbo.eu/s/kW3
out meta; Results from out or out body + Metadata (timestamp, version, changeset, user name & user id who last touched the feature) http://overpass-turbo.eu/s/kW0
out count; Returns just the total number of matching features for a query. No geometry/tags/metadata http://overpass-turbo.eu/s/kW7
out n; eg: out 2; Outputs only n number of elements http://overpass-turbo.eu/s/kW9
out bb; Provides a bbox for each element returned for the query. Geojson export of the result gives these boundaries the cooridnates, instead of actual geoemtries http://overpass-turbo.eu/s/kWa
out center; Provides a center point of each feature's bbox. Geojson export of the feature has these center points instead of the actual geomtry. http://overpass-turbo.eu/s/kWb

Geojson export result of example query:

out body/out geom out bb out center
body bb center

These verbosity statements can be put together like the example here.

[out:json][timeout:25];
// gather results
(
  // query part for: “highway=residential”
  node["highway"="residential"]({{bbox}});
  way["highway"="residential"]({{bbox}});
  relation["highway"="residential"]({{bbox}});
);
// print results
out geom(52.5077754,13.2216702,52.5111171,13.2282497);
out meta;
out count;

In such a case data o/p is generated for each of these statement and combined together in the Data tab of overpass turbo page. While exporting the data from this query as geojson, the result will be similar to what an out meta; statement returns.

Sort order of out statements

Overpass Statements What does it return?
out; or out asc; Outputs elements in ascending order of the id.
out qt; Outputs elements based on quadtile index/geographical order

Recurse down

>; is called a recurse down statement. What does it do?

[out:json][timeout:25];
// gather results
(
  // query part for: “highway=residential”
  node["highway"="residential"]({{bbox}});
  way["highway"="residential"]({{bbox}});
  relation["highway"="residential"]({{bbox}});
);
// print results
out;
>;
out skel qt;

Above query searches for all ways that has highway=residential tag in a given bbox and retrieves ,

  • all tags associated to that particular way
  • all unique identifiers of nodes belonging to the way.

What we need more is the geometry/coordinates of each node. This has to be done for each node id. Instead of writing multiple statements, one single recursive query statement is written and all node geometries are obtained.

Clone this wiki locally