[GIS] Overpass API query that returns amenities and filters those without a name tag

overpass-api

I'm trying to query all the amenities in my neighborhood but find that the result set has a bunch of amenity-nodes without a name tag.

I want to filter these nodes out.

After reading the Overpass Language reference wiki (here) – http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Tag_request_clauses_.28or_.22tag_filters.22.29

where it says

["key"!~"value"] filter objects tagged with this key but a value not 
                 matching a regular expression

The following returns nothing.

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=*”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “amenity=*”
  node["amenity"];node["name"!~"^$"]({{bbox}});
  way["amenity"]({{bbox}});
  relation["amenity"]({{bbox}});

);
// print results
out body;
>;
out skel qt;

Best Answer

Type

amenity=* and name=*

in query wizard and remove [name] from ways and relations

It gives

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=* and name=*”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “amenity=* and name=*”
  node["amenity"]["name"]({{bbox}});
  way["amenity"]({{bbox}});
  relation["amenity"]({{bbox}});
);
// print results
out body;
>;
out skel qt;

It will list all ways, all relations and named nodes.