Overpass API – How to Run a Query in Overpass-Turbo

overpass-apiquery-layer

I am trying to write a query that shows all the highway in an area, except for one feature in overpass-turbo. The query wizard in overpass-turbo has highway=* which shows everything. But I want to select everything except one.
For example: all highway except residential roads.

Best Answer

You could ask the wizard for:

(highway!=footway) and type:way

But this will return everything that has no defined value for highway at all, such as walls, streams, electrical lines and countless other things.

So what you probably want is to ask the wizard for:

(highway=*) and (highway!=residential) and type:way

This will return ways (lines, but no points or polygons) with a value for highway that is defined and anything but residential. OpenStreetMap has a fairly loose definition of highway, and you may get results like:

  • highway = raceway
  • highway = steps
  • highway = cycleway
  • highway = corridor

Always consult the OpenStreetMap wiki for highway (or whichever element you intend to use) before downloading it in this way.

I make some use of OpenStreetMap data downloaded through Overpass, and after a lot of messing with the query syntax, I gave up. Instead, I defined a short and very permissive query, and downloaded that. It contained a lot of elements I didn't want, so I wrote a Python script that filtered them out. This allowed me to keep count of high many elements I was discarding and how many I was keeping. But Overpass Turbo is an excellent place to get started.