rel
[boundary=administrative]
[name =Pfungen ]
;
// >;
out // <relation id="1682188">
// meta // <relation id="1682188" version="5" timestamp="2016-12-07T02:43:55Z" changeset="44224658" uid="339581" user="nyuriks">
// bb // Bounding box for each selected element?
// // <relation id="1682188">
// // <bounds minlat="47.4974379" minlon="8.6176417" maxlat="47.5218535" maxlon="8.6611408"/>
// center // <relation id="1682188">
// <center lat="47.5096457" lon="8.6393912"/>
// geom // include coordinates in <nd …> tags.
// Seems to be required to draw ways on the map.
// skel // Don't emit <tag k="…" v="…"> nodes.
// ids // Output IDs only
// tags // Output IDs and tags
count // get number of nodes, ways, relations and their total.
// qt // Sort by quadtile index
// This is roughly geographical and significantly faster than order by ids.
// See also https://gis.stackexchange.com/a/187754:
// body // ?
// popup // Invalid parameter «popup»
;
Named set
The content of a set can be outputted by prepending out statement with the name of the set (and the usual dot):
(
make t1
num = 42,
txt = 'hello world';
make t2
num = 99,
txt = 'ninety-nine';
) -> .x;
.x out;
bb
out bb reports the bounding box of relations in a <bounds> tag with minlat, minlon, maxlat and maxlon attributes, for example:
Special field names (starting with two colons (::…)) make it easy to export OSM data as CSV:
[out:csv (
//
// Tag names:
//
amenity ,
name ,
'addr:street' ,
'addr:housenumber',
//
// Special field names:
//
::id , // OSM object ID
::type , // Object type (node, way or relation)
::otype , // Object type as numeric value
::lat , // Latitude + Longitude (available for nodes
::lon , // or ways with 'out center')
//
// Field names available with 'out meta'
//
::version , // OSM object's version number
::timestamp , // Timestamp of last modificatio
::changeset , // Changeset in which the object was changed
::uid , // User id of mapper
::user ; // User name of mapper
//
// Header and separator
//
true ;
" | "
)];
{{geocodeArea: Pfungen }} -> .pfungen;
nwr[amenity](area.pfungen);
out meta;
Some field names are available for the out count statement
[out:csv (
//
// Special field names (for 'out count')
//
::count , // Returns total number of objects (nodes, ways, relations and areas) in inputset
::"count:nodes" , // Returns number of nodes in inputset
::"count:ways" , // Returns number of ways in inputset
::"count:relations", // Returns number of relations in inputset
::"count:areas" ; // Returns number of areas in inputset
//
// Header and separator
//
true ;
" | "
)];
{{geocodeArea: Pfungen }} -> .pfungen;
nwr(area.pfungen);
out count;
ids
Print the ids of all nodes whose name is Matterhorn and are also peaks. It turns out that there are more than just one Matterhorn…
node
[name = Matterhorn]
[natural = peak ];
out ids;
tags
relation[admin_level=2];
out tags;
The previous query only emits relations and their tags, without also listing the relations' members:
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API 0.7.59.2 0994154d">
<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
<meta osm_base="2023-03-11T11:04:42Z"/>
<relation id="9407">
<tag k="ISO3166-1" v="AD"/>
….
<tag k="name" v="Andorra"/>
</relation>
<relation id="11980">
<tag k="ISO3166-1" v="FR"/>
…
<tag k="name" v="France (terres)"/>
…