1
1

Hey, you can I ask Overpass to just give me back Objects with just one particular tag and no other tags. e.g. if a object has the tag building=yes it should be displayed if it has building=yes and addr:city=whatever it shouldn't?

How can i make that happen ? Thanks for your answers!

asked 03 Jun '13, 20:05

hno2's gravatar image

hno2
51336
accept rate: 0%

Update September 2014: Now that Overpass API also supports regular expressions for keys, this kind of query is now possible. See my answer below for details.

(10 Sep '14, 10:12) mmd

4 Answers:
3

I don't know if overpass API can count tags. Neither do I know if you can query "your" objects.

If you are looking for buildings wighout house numbers, you could either use Simon's no address layer or you could use this overpass query (objects that have a building tag set and don't have an addr:housenumber tag):

(
 node({{bbox}})["building"]
  ["addr:housenumber"!~".*"];
 way({{bbox}})["building"]
  ["addr:housenumber"!~".*"];
 rel({{bbox}})["building"]
  ["addr:housenumber"!~".*"];
);
(._;>;);
out;

HTH /al

permanent link

answered 04 Jun '13, 13:21

_al's gravatar image

_al
84521018
accept rate: 4%

1

Thanks, I was looking for a query to find ways with addr:interpolation but without addr:street

(
 node({{bbox}})["addr:interpolation"]
  ["addr:street"!~".*"];
 way({{bbox}})["addr:interpolation"]
  ["addr:street"!~".*"];
 rel({{bbox}})["addr:interpolation"]
  ["addr:street"!~".*"];
);
(._;>;);
out;
(10 Oct '13, 20:17) cyph3r
1

Overpass API cannot count tags yet. There's an open issue for that on Github: https://github.com/drolbr/Overpass-API/issues/197

(22 Mar '15, 17:07) mmd
3

A combination of the difference operator and regular expressions for keys can make this happen. Unfortunately, you cannot use negative look-ahead (?!) for regular expressions, which makes the whole story very complex (see this stackoverflow post on how to build such an expression).

That's why I resort to a simplified approach and exclude buildings, which have any tags that don't start with a letter "b". However, the basic principle is the same.

[bbox:{{bbox}}];
((
// retrieve all buildings    
  way[building=yes];
// and remove...    
  - 
// all buildings which also have a tag not starting with "b"    
  way[building=yes][~"^[^b].*$"~"."]; 
); >; );
out;

Try in Overpass Turbo: http://overpass-turbo.eu/s/4Z9

permanent link

answered 10 Sep '14, 09:02

mmd's gravatar image

mmd
5.6k14988
accept rate: 37%

0

http://overpass-turbo.eu/s/rjM has an example of query that is using tag counting. It will find poorly tagged object - with only tourism=attraction or tourism attraction + name tag in Poland,

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“addr:housenumber=* and name=* and type:node and aeroway!=* and amenity!=* and craft!=* and historic!=* and leisure!=* and man_made!=* and office!=* and power!=* and railway!=* and shop!=* and tourism!=* in Polska”
*/
[out:xml]/*fixed by auto repair*/[timeout:2500];
// fetch area “Polska” to search in
{{geocodeArea:Polska}}->.searchArea;
// gather results
(
  // query part for: “"addr:housenumber"=* and name=* and aeroway!=* and amenity!=* and craft!=* and historic!=* and leisure!=* and man_made!=* and office!=* and power!=* and railway!=* and shop!=* and tourism!=*”
 node[tourism=attraction](if:count_tags()==1)(area.searchArea);
   node[tourism=attraction][name](if:count_tags()==2)(area.searchArea);
);
// print results
out meta;/*fixed by auto repair*/
>;
out meta qt;/*fixed by auto repair*/

query was provided by RicoElectrico, thanks! source: https://forum.openstreetmap.org/viewtopic.php?pid=661266#p661266

permanent link

answered 29 Aug '17, 08:58

Mateusz%20Konieczny's gravatar image

Mateusz Koni...
3463616
accept rate: 0%

edited 29 Aug '17, 08:59

-2

I'm not sure what you mean.

Concerning the output format, Overpass API prints for an object always either all tags or no tags at all.

If you want to find an object with a certain tag but not a certain other tag, you can the solution provided by _al above.

permanent link

answered 05 Jun '13, 07:34

Roland%20Olbricht's gravatar image

Roland Olbricht
6.4k35986
accept rate: 35%

2

As far as I understand he is looking for a solution to find objects which only have one tag - the specified tag - and no other tags at all.

(05 Jun '13, 08:14) scai ♦
1

Thats right, e.g a node with the tag addr:street: Obama Alley and without any other tags should be printed a node with addr:street and addr:country not. But I already solved my problem with an other possible solution

(05 Jun '13, 16:45) hno2

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×585
×377
×90

question asked: 03 Jun '13, 20:05

question was seen: 6,782 times

last updated: 29 Aug '17, 08:59

powered by OSQA