[GIS] Can you restrict which OSM tags are returned by Overpass API

openstreetmapoverpass-api

I've been reading up on Overpass syntax and I think I get the basics. For example, let's say I want to get the IDs and coordinates of every town in Andorra that OSM has a record of:

http://overpass.osm.rambler.ru/cgi/interpreter?data=[out:json];area[%22ISO3166-1%22=%22AD%22][admin_level=2];(node[%22place%22=%22town%22](area););out%20ids%20center;

This is great for keeping the data stream light — say, if you're targeting smartphones and are trying to be conscious of data plan costs.

Now, what if I just want to get the "name" tag of each of these towns in addition to the ID and center? I know how to get all of the tags — just add " tags" right before the final semicolon — but that gives me a whole bunch of tags I don't want and a bloaty data stream.

Does anyone know whether/how one can selectively include tags in the Overpass output stream?

That is, not filtering nodes by tag but rather filtering tags by tag name.

Best Answer

You can easily achieve this via CSV output. Read more about it in the Overpass QL documentation.

[out:csv(::id, ::lat, ::lon, name)];
area["ISO3166-1"="AD"][admin_level=2];
node[place=town](area);
out center;

Try it out: http://overpass-turbo.eu/s/qag

Related Question