Overpass API Queries Overpass API Queries

February 17, 2022

openstreetmap

Having been work with Overpass API and developing londinium.com I have spent a great deal of time learning Overpass_QL

I wanted to put together a blog post with all the Overpass Queries I have been using in on place.

You can test these out using Overpass Turbo where you can run each example. You may need to adapt the BBOX area for the search and edit them for your purpose.

Get a Feature eg. supermarket

[out:json][timeout:25];
(
  nwr[shop=supermarket]({{bbox}});
);
// print results
out body;
>;
out skel qt;

Get everything in a Place

nwr[shop]; nwr[amenity]["name"]; nwr[tourism]["name"]; nwr[sport]["name"]; nwr[building]["name"]; nwr[leisure]["name"]; nwr[public_transport]["name"];nwr[office]["name"];

Get a Brand eg. waitrose

[out:json][timeout:25];
(
  nwr["shop"]["name"="Waitrose"]({{bbox}});
  nwr["shop"]["brand"="Waitrose"]({{bbox}});
  nwr["shop"]["operator"="Waitrose"]({{bbox}});
);
// print results
out body;
>;
out skel qt;

get a single NWR Node / Way / Relation, eg Lords Cricket Ground

[out:json];
  relation(9653407);
// print results
out body; >; out skel qt;

London Overground outpus as a csv

[out:csv(::type,::id,network,type,name)][timeout:25];
{{sel=["network"~"London Overground"]["type"~"route"]}}
(
  relation{{sel}};
);
out meta qt;

GAY=yes with website

[bbox:{{bbox}}][out:xml][timeout:30];(
  nwr[gay=yes][!lgbtq][website];
);out meta;>;out meta qt;

Nodes and Ways with Images

[out:json][timeout:25];
{{geocodeArea:London}}->.searchArea;
(
  node["image"](area.searchArea);
  way["image"](area.searchArea);
);
out body;
>;
out skel qt;

Communication towers

node
  ["tower:type"=communication]
  ["communication:mobile_phone"=yes]
  ({{bbox}});
out;

A Postcode like query

[out:json][timeout:25];
(
  node["addr:postcode"~"^HA8"];
  way["addr:postcode"~"^HA8"];
  relation["addr:postcode"~"^HA8"];
);
out body;
>;
out skel qt;

AREA NAME

( area[name="Harrow"][admin_level=9]; )->.searchArea;
(
  way[highway=cycleway](area.searchArea);
  way[highway=path][bicycle=designated](area.searchArea);
  way[highway][cycleway]["cycleway"!~"no|opposite"](area.searchArea);
  way[highway]["cycleway:left"!=no]["cycleway:left"](area.searchArea);
  way[highway]["cycleway:right"!=no]["cycleway:right"](area.searchArea);
);
out geom;
make stats length=sum(length()),section_lengths=set(length());
out;

If you would like to contact me with this form on londinium.com, ilminster.net or via Twitter @andylondon