This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Find objects with duplicate tag

0

I would like to find all relations that have duplicate wikidata tags. I saw finding dup nodes, but cannot figure out how to adaapt my query to it:

[out:csv(admin_level,::id,wikidata,name,wikipedia,boundary,type,alt_name,designation)]; ( rel["admin_level"]["wikidata"]; );

asked 03 Jan '17, 08:06

nyuriks's gravatar image

nyuriks
71226
accept rate: 0%

edited 03 Jan '17, 19:34

tyr_asd's gravatar image

tyr_asd
1.2k51927


One Answer:

0

The new OSM+Wikidata SPARQL service can now do it with this query.

SELECT ?osmid ?adminlvl ?wd ?wdLabel {
  # find relation with a wikidata tag
  ?osmid osmm:type 'r' ;
         osmt:wikidata ?wd ;
         osmt:admin_level ?adminlvl .

  # add user's or english label to the found wikidata
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

  # the ?wd variable must also be matching this subquery
  # it finds wd tags that appear more than once
  { SELECT ?wd { 
    ?osmid osmm:type 'r' ;
           osmt:wikidata ?wd ;
           osmt:admin_level ?adminlvl .
    }
    GROUP BY ?wd
    HAVING (COUNT(*) > 1)
  }

} LIMIT 10

answered 06 Sep '17, 09:08

nyuriks's gravatar image

nyuriks
71226
accept rate: 0%

Source code available on GitHub .