SPARQL examples

From OpenStreetMap Wiki
Jump to: navigation, search

Contents

Simple Queries

These basic queries help to understand SPARQL, the Wikibase RDF format and OSM RDF format .

List all OSM objects with a place tag

Get started with this simple query to list OSM objects by a particular type or tag. (Compare it with a similar Overpass Query).

SELECT * WHERE {
  # Limit to subjects that have an OSM type ('n', 'r', 'w').
  # Replace ?osmType with a string 'r' to show only relations.
  ?osmId osmm:type ?osmType .

  # Limit to subjects that have an OSM tag `place`
  # Replace ?place with a string 'city' to filter the tag value to `place=city`
  ?osmId osmt:place ?place  .

  # Uncomment this line to only show places that have no `name:en` tag
  # FILTER NOT EXISTS { ?osmId osmt:name:en ?nameen . }

} LIMIT 50
Run it (edit query)

Quality Control

Find mismatching "wikipedia" and "wikidata" tags (faster)

SELECT * WHERE {
  # must have both WP and WD tags
  ?osmId osmt:wikipedia ?wp ;
         osmt:wikidata ?wd .
  
  # ignore non-standard values for wp & wd
  FILTER (ISURI(?wp) && ISURI(?wd))
  
  # when WP sitelink is not a part of the WD entry
  FILTER NOT EXISTS {
    ?wp schema:about ?wd .
  }
} LIMIT 10
Run it (edit query)

mismatching "wikipedia" and "wikidata" tags (slower)

#defaultView:Map
SELECT ?osmId ?wdLabel ?wpFromOSM ?wpFromWd ?wd ?loc WHERE {
  ?osmId osmt:wikidata ?wd ;         # osm object must have a "wikidata" tag
         osmt:wikipedia ?wpFromOSM ; # osm object must have a "wikipedia" tag
         osmm:loc ?loc .             # get object's location

  # wikipedia tag link must not be listed in the corresponding wikidata object
  FILTER NOT EXISTS { ?wpFromOSM schema:about ?wd . }

  OPTIONAL {
    # if Wikidata has another link in the same domain, show it
    ?wpFromWd schema:about ?wd .
    FILTER( SUBSTR( STR(?wpFromOSM), 0, 25 ) = SUBSTR( STR(?wpFromWd), 0, 25 ) )
  }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Run it (edit query)

OSM objects linking to Wikipedia disambiguation pages

#defaultView:Map
SELECT ?osmId ?wdLabel ?wd ?wpTag ?loc WHERE {
  # Limit to subjects that have a tag called "wikidata"
  ?osmId osmt:wikidata ?wd ;
         osmm:loc ?loc .

  # Include Wikipedia tag if it exists
  OPTIONAL { ?osmId osmt:wikipedia ?wpTag . }
  # Pick the first available language for the wikidata entry (creates ?wdLabel value)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it,pl,ru,es,sv,nl" }

  # ?wd must be an "instance of" a disambiguation page, or an instance
  # of some type, which itself is a (sub-)*subclass of a disambig page.
  ?wd wdt:P31/wdt:P279* wd:Q4167410 .

  # Optionally, find pl:* wikipedia tags (point to Polish wiki)
  # For performance, remove the "OPTIONAL {" and "}" part above
  #  FILTER( STRSTARTS(STR(?wpTag), 'https://pl.wikipedia')) .

  # Or, instead, only show Wikidata items that have a Polish WP article
  # You may also want to add ?article to the list of fields returns by SELECT statement
  #  ?article schema:about ?wd .
  #  ?article schema:isPartOf <https://pl.wikipedia.org/>.

  # Optionally, limit to just ways (can be 'n', 'r', 'w')
  # ?osmId osmm:type 'w' .

  # Optionally, restrict OSM objects to those that have a specific tag (and value)
  #  ?osmId osmt:place 'city' .        # exact string matching
  #  ?osmId osmt:name:en ?nameen .     # unless filtered, matches all objects with this tag
  #  FILTER( regex(?nameen, "A.b") )   # filter name:en to match a regex. Not very efficient

  # Limit locations to a given bounding box (USA in this case)
  # For some reason, wikibase:box is timing out - tinyurl.com/yc2kd4xs
  # ?osmId osmm:loc ?loc .
  # BIND( geof:longitude(?loc) as ?longitude )
  # BIND( geof:latitude(?loc) as ?latitude )
  # FILTER( ?longitude > -126.2 && ?longitude < -64 && ?latitude > 25 && ?latitude < 49.6)
}
Run it (edit query)

OSM objects linking to Wikipedia "list" pages

SELECT ?osmId ?wdLabel ?osmType ?wd WHERE {
  # Limit to subjects that have an OSM type ('n', 'r', 'w').
  # Replace ?osmType with a string 'r' to show only relations.
  ?osmId osmm:type ?osmType .

  # Limit to subjects that have a tag called "wikidata"
  ?osmId osmt:wikidata ?wd .

  # Optionally, restrict OSM objects to those that have a specific tag (and value)
  # ?osmId osmt:place 'city' .        # exact string matching
  # ?osmId osmt:name:en ?nameen .     # unless filtered, matches all objects with this tag
  # FILTER( regex(?nameen, "A.b") )    # not very efficient

  # ?wd must be "instance of" list page, or instance of an item which is a subclass(es) of it.
  ?wd wdt:P31/wdt:P279* wd:Q13406463 .

  # Pick the first available language for the wikidata entry (creates ?wdLabel value)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,fr,it,pl,ru,es,sv,nl" . }
}
LIMIT 100
Run it (edit query)

Find places located too far from Wikidata's

This query shows OSM objects, whose location is more than 50km from where corresponding Wikidata item is located. The query orders by distance, and only shows top 50 results that are furthest away. See also distance function.

SELECT ?osmId ?wd ?wdLabel ?dist WHERE {
  # ?osmId osmm:type 'n' .       # Optionally filter by the type of OSM object
  ?osmId osmm:loc ?osmLoc .    # With location value
  ?osmId osmt:wikidata ?wd .   # With "wikidata" tag
  ?wd wdt:P625 ?wdLoc .        # Corresponding Wikidata must also have location
  BIND(geof:distance(?wdLoc, ?osmLoc) as ?dist)   # Calculate distance between OSM's and WD's
  FILTER(?dist > 50)  # Filter by minimum distance. Some large objects might be correct with even greater distance

  # For the Wikidata entry, get its label in current user's language, or in the first available
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it,pl,ru,es,sv,nl" . }
}
ORDER BY DESC(?dist)
LIMIT 50
Run it (edit query)

Objects linking to place of business with "wikidata" tag instead of "operator:wikidata" tag

SELECT ?osmId ?wdLabel ?wd ?wpTag WHERE {
  # Limit to subjects that have an OSM type ('n', 'r', 'w').
  # Replace ?osmType with a string 'r' to show only relations.
  ?osmId osmm:type ?osmType .

  # Limit to subjects that have a tag called "wikidata"
  ?osmId osmt:wikidata ?wd .

  # Filter out entries that have identical wikidata and operator:wikidata
  # In theory there should only be one WP tag
  FILTER NOT EXISTS { ?osmId osmt:operator:wikidata ?wd . }

  # Include Wikipedia tag if it exists
  OPTIONAL { ?osmId osmt:wikipedia ?wpTag . }

  # Optionally, find pl:* wikipedia tags (point to Polish wiki)
  # For performance, remove the "OPTIONAL {" and "}" part above
  # FILTER( STRSTARTS(STR(?wpTag), 'https://pl.wikipedia')) .

  # Or, instead, only show Wikidata items that have a Polish WP article
  # You may also want to add ?article to the list of fields returns by SELECT statement
  #  ?article schema:about ?wd .
  #  ?article schema:isPartOf <https://pl.wikipedia.org/>.

  # Optionally, restrict OSM objects to those that have a specific tag (and value)
  #  ?osmId osmt:place 'city' .        # exact string matching
  #  ?osmId osmt:name:en ?nameen .     # unless filtered, matches all objects with this tag
  #  FILTER( regex(?nameen, "A.b") )    # filter name:en to match a regex. Not very efficient

  # ?wd must be "instance of" an enterprise, or instance of an item which is a subclass(es) of it.
  ?wd wdt:P31/wdt:P279* wd:Q4830453 .

  # Pick the first available language for the wikidata entry (creates ?wdLabel value)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it,pl,ru,es,sv,nl" . }
}
LIMIT 50
Run it (edit query)

Show the top most common OSM objects that represent places of business

Same as the above, but counts unique Wikidata IDs, and shows the most common ones

SELECT ?wd (SAMPLE(?wdLabel) AS ?wdLabel) (COUNT(?osmId) as ?count) WHERE {
  # Limit to subjects that have an OSM type ('n', 'r', 'w').
  # Replace ?osmType with a string 'r' to show only relations.
  ?osmId osmm:type ?osmType .

  # Limit to subjects that have a tag called "wikidata"
  ?osmId osmt:wikidata ?wd .

  # Filter out entries that have identical wikidata and operator:wikidata
  # In theory there should only be one WP tag
  FILTER NOT EXISTS { ?osmId osmt:operator:wikidata ?wd . }

  # Include Wikipedia tag if it exists
  OPTIONAL { ?osmId osmt:wikipedia ?wpTag . }

  # Optionally, find pl:* wikipedia tags (point to Polish wiki)
  # For performance, remove the "OPTIONAL {" and "}" part above
  # FILTER( STRSTARTS(STR(?wpTag), 'https://pl.wikipedia')) .

  # Or, instead, only show Wikidata items that have a Polish WP article
  # You may also want to add ?article to the list of fields returns by SELECT statement
  #  ?article schema:about ?wd .
  #  ?article schema:isPartOf <https://pl.wikipedia.org/>.

  # Optionally, restrict OSM objects to those that have a specific tag (and value)
  #  ?osmId osmt:place 'city' .        # exact string matching
  #  ?osmId osmt:name:en ?nameen .     # unless filtered, matches all objects with this tag
  #  FILTER( regex(?nameen, "A.b") )    # filter name:en to match a regex. Not very efficient

  # ?wd must be "instance of" an enterprise, or instance of an item which is a subclass(es) of it.
  ?wd wdt:P31/wdt:P279* wd:Q4830453 .

  # Pick the first available language for the wikidata entry (creates ?wdLabel value)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it,pl,ru,es,sv,nl" . }
}
group by ?wd
ORDER BY DESC(?count)
LIMIT 50
Run it (edit query)


Find when more than one relation link to the same Wikidata ID

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
Run it (edit query)

Show relations with no sub-relations or nodes, having same wikidata tag with the parent **SLOW**

SELECT
  ?rel
  (sum(?failed) as ?failCount)
  (count(?mwd) as ?memberWithWdCount)
  (count(?member) as ?memberCount)

WHERE {
  # Find relations with wikidata tag and at least one member
  ?rel osmm:type 'r';
       osmt:wikidata ?wd;
       osmm:has ?member .

  # Get member's type
  ?member osmm:type ?mtype .

  # Get member's wikidata tag if it exists
  OPTIONAL { ?member osmt:wikidata ?mwd }

  # If any of the conditions are met, set ?failed to 1.
  # The sum of ?failed must be 0 for the relation to be shown
  BIND (if((?mtype='r' || ?mtype='n' || bound(?mwd) && ?mwd!=?wd), 1, 0) as ?failed)
}
GROUP BY ?rel
HAVING (?memberWithWdCount > 0 && ?failCount = 0)
ORDER BY DESC(?memberCount)
LIMIT 20
Run it (edit query)


Objects whose Wikipedia tag does not exist in Wikidata

SELECT ?osmId ?wpTag WHERE {
  # Limit to subjects that have a tag called "wikipedia"
  ?osmId osmt:wikipedia ?wpTag .

  # The article title must not be used in Wikidata
  FILTER NOT EXISTS { ?wpTag schema:isPartOf ?anySite . }

  # OSM item must not have a wikidata tag
  FILTER NOT EXISTS { ?osmId osmt:wikidata ?anyWd . }

  # Optionally, find pl:* wikipedia tags (point to Polish wiki)
  #  FILTER( STRSTARTS(STR(?wpTag), 'https://pl.wikipedia')) .

  # Optionally, limit to just ways (can be 'n', 'r', 'w')
  #  ?osmId osmm:type 'w' .

  # Optionally, restrict OSM objects to those that have a specific tag (and value)
  #  ?osmId osmt:place 'city' .        # exact string matching
  #  ?osmId osmt:name:en ?nameen .     # unless filtered, matches all objects with this tag
  #  FILTER( regex(?nameen, "A.b") )   # filter name:en to match a regex. Not very efficient
}
LIMIT 10
Run it (edit query)

Names and languages

Places without English name tag, and without English label in Wikidata

SELECT ?osmId ?osmType ?place ?wd WHERE {
  ?osmId osmm:type ?osmType .
  ?osmId osmt:place ?place .
  ?osmId osmt:wikidata ?wd .
  FILTER NOT EXISTS { ?osmId osmt:name:en ?nameen . }

  OPTIONAL { ?wd rdfs:label ?label FILTER(lang(?label) = "en") }
  FILTER(!BOUND(?label))
}
LIMIT 50
Run it (edit query)


OSM places without name:fr that are most popular in French wiki

SELECT ?label ?osmId ?place ?wd ?popularity WHERE {
  # Limit to subjects that have an OSM tag `place`
  # Replace ?place with a string 'city' to filter the tag value to `place=city`
  ?osmId osmt:place ?place  .

  # This will limit the results to places which do not have a `name:en` tag:
  FILTER NOT EXISTS { ?osmId osmt:name:fr ?namefr . }

  # Must have wikidata tag
  ?osmId osmt:wikidata ?wd .

  # the wikidata must have a frwiki page, and it must be popular
  # note that some less popular pages may not have a pageview value
  ?sitelink schema:isPartOf <https://fr.wikipedia.org/> ;
            schema:about ?wd ;
            pageviews: ?popularity .

  # Wikidata must have a French label
  ?wd rdfs:label ?label .
  FILTER(lang(?label) = "fr")
}
ORDER BY DESC(?popularity)
LIMIT 50
Run it (edit query)


Find Irish places with name != name:ga or name:en

#defaultView:Map
SELECT ?osmid ?name ?nameen ?namega ?loc {
  # subjects must have all 3 tags: name, name:en, name:ga
  ?osmid osmt:name ?name ;
         osmt:name:en ?nameen ;
         osmt:name:ga ?namega .

  # "name" is not the same as "name:ga" or "name:en"
  FILTER (?name != ?nameen && ?name != ?namega)

  # Limit to those that are within 500km around Ireland "center"
  # The center is taken from Wikidata:  Ireland (Q27)  location (P625)
  wd:Q27 wdt:P625 ?irelandCenter .
  SERVICE wikibase:around {
    ?osmid osmm:loc ?loc .
    bd:serviceParam wikibase:center ?irelandCenter .
    bd:serviceParam wikibase:radius "500" .
  }
} LIMIT 100
Run it (edit query)

Miscellaneous

Calculate simple centroid of a relation

The location is calculated by taking all relation's members, and averaging all of their longitudes and latitudes.
Note: This is not very accurate, especially for relations whose members are near anti-meridian.

#defaultView:Map
SELECT
  ?rel
  # Calculate average lng and lat, and reconstruct a geopoint literal
  (strdt(
    concat(
      'Point(', STR(xsd:float(AVG(?longitude))), ' ', STR(xsd:float(AVG(?latitude))), ')'
    ), geo:wktLiteral
  ) as ?loc)
WHERE {

  # Limit to just a few relation IDs, otherwise the server times out
  BIND( osmrel:13 as ?rel )

  # Subject must be a relation, and must not already have a location
  ?rel osmm:type 'r' .
  FILTER NOT EXISTS { ?rel osmm:loc ?relLoc . }

  # Relation must have members, and those members must have locations
  ?rel osmm:has ?member .
  ?member osmm:loc ?loc .

  # Extract each member's longitude and latitude
  BIND( geof:longitude(?loc) as ?longitude )
  BIND( geof:latitude(?loc) as ?latitude )
}
GROUP BY ?rel  # group all found items by relation
LIMIT 10
Run it (edit query)


Find all US states, and show their flags

#defaultView:Map
SELECT * WHERE {

  # This sub-query gets all top-level subdivisions of a given country

{SELECT REDUCED ?id ?idLabel
	   (SAMPLE(?flagImg) as ?flagImg)
	   (SAMPLE(?page) as ?page)
WHERE {
  # Configurable parameters:
  # ?country is a country
  BIND(wd:Q30 as ?country)
  # ?types is administrative subdivisions we seek for this country
  VALUES ?types { wd:Q34876 wd:Q7275 }
  # No serviceable parts beyond this point
  # Located in the administrative territorial entity of the whole country, but not sub-entity
  ?id wdt:P131 ?country .
  # We want it to be of this type in a country, and have a capital
  FILTER EXISTS { ?id (wdt:P31/wdt:P279*) ?types ;
                         wdt:P17 ?country . }
  # Excluding the country itself
  FILTER(?id != ?country)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  OPTIONAL { ?id wdt:P41 ?flagImg }
  OPTIONAL {
      ?page schema:about ?id .
      ?page schema:isPartOf <https://en.wikipedia.org/> .
  }

} GROUP BY ?id ?idLabel}


  # For each found id, find osm object that links to it, and find its location
  ?osmid osmt:wikidata ?id .
  ?osmid osmm:loc ?loc .
}
Run it (edit query)


Show a map of all schools, universities, and kindergartens near a place

#defaultView:Map
# "layer" keyword breaks all results into multiple groups
# Use the layers button in the upper right corner of the map to filter
SELECT ?marketLoc ?marketName (?amenity as ?layer) ?osmid WHERE {

  # We are only interested in these types of amenities
  VALUES ?amenity { "kindergarten" "school" "university" "college" }

  # Find anything with tag "amenity", and that has a name and location
  ?osmid osmt:amenity ?amenity ;
         osmt:name ?marketName ;
         osmm:loc ?marketLoc .

  # Get the center of Jersey City from Wikidata
  wd:Q26339 wdt:P625 ?myLoc .

  # Calculate the distance,
  # and filter to just those within 5km
  BIND(geof:distance(?myLoc, ?marketLoc) as ?dist)
  FILTER(?dist < 5)
}
Run it (edit query)

Use regex to search tags: a word in wikipedia tag ends in a "ville"

SELECT ?osmId ?place ?wp ?loc WHERE {
  # must have place and wikipedia tags
  ?osmId osmt:place ?place ;
         osmt:wikipedia ?wp .
  
  # Find any wikipedia link with a word ending in "ville"
  # Unlike other tags, wikipedia and wikidata tags are stored as URIs,
  # so they must be converted into a string before using string functions.
  FILTER (regex(str(?wp), "ville([^a-z]|$)", "i"))
  
  # If location metatag exists, include it
  # Use "Table" button to switch to the map view
  OPTIONAL { ?osmId osmm:loc ?loc . }
}
LIMIT 10
Run it (edit query)

Find "Featured" wiki articles with location, but without OSM connection

SELECT ?sitelink ?wdLabel WHERE {

  # Wikidata item must have a location within the given circle
  # Use the location value from WD Poland entry (Q36) for the center
  # Note that if bounding box is available, it might be faster
  wd:Q36 wdt:P625 ?center .
  SERVICE wikibase:around {
    ?wd wdt:P625 ?loc .
    bd:serviceParam wikibase:center ?center .
    bd:serviceParam wikibase:radius "300" . #km
  }
  
  # There must not be an OSM object with this wikidata id
  FILTER NOT EXISTS { ?osm1 osmt:wikidata ?wd . }

  # There must not be an OSM object with this wikipedia link
  FILTER NOT EXISTS { ?osm2 osmt:wikipedia ?sitelink . }

  # Sitelink must be present in this wiki, with the given badges
  # A much slower query can do multiple badge types. Uncomment this:
  #  VALUES ?badges { wd:Q17437796 wd:Q17437798 }
  # And replace  wd:Q17437796  with  ?badges
  ?sitelink schema:isPartOf <https://pl.wikipedia.org/> ;
            schema:about ?wd ;
            wikibase:badge wd:Q17437796 .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,pl" } .

} LIMIT 10
Run it (edit query)


Show a map of the user's edits between dates, if edit is still last, by obj type

#defaultView:Map
SELECT * WHERE {

  ?osmId osmm:user 'nyuriks' ;
         osmm:loc ?loc ;
         osmm:type ?layer .

  # Filter by timestamp
  ?osmId osmm:timestamp ?ts .
  FILTER ("2017-03-01T00:00:00Z"^^xsd:dateTime < ?ts &&
          ?ts < "2017-03-05T00:00:00Z"^^xsd:dateTime)
}
Run it (edit query)


Find all wikidata items near the specific osm object

#defaultView:Map
SELECT ?loc ?wd ?wdLabel ?distance ?enSite ?esSite ?deSite ?frSite ?ruSite WHERE {
  
  # for convenience, define constant parameter of the central object
  BIND (osmway:157474680 as ?osmId)
  BIND (10 as ?radius)  # in km
  
  # get object's location to use as a center of the search
  ?osmId osmm:loc ?center .

  # find all wikidata items in the close proximity
  SERVICE wikibase:around {
    ?wd wdt:P625 ?loc .
    bd:serviceParam wikibase:center ?center .
    bd:serviceParam wikibase:radius ?radius .
  }

  # Calculate distance between OSM's and WD's
  BIND(geof:distance(?center, ?loc) as ?distance)

  # For the Wikidata entry, get its label in current user's language, or in the first available
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it,pl,ru,es,sv,nl" . }

  # Find common wikipedia sitelinks
  OPTIONAL { ?enSite schema:about ?wd ;
                     schema:isPartOf <https://en.wikipedia.org/> . }
  OPTIONAL { ?esSite schema:about ?wd ;
                     schema:isPartOf <https://es.wikipedia.org/> . }
  OPTIONAL { ?deSite schema:about ?wd ;
                     schema:isPartOf <https://de.wikipedia.org/> . }
  OPTIONAL { ?frSite schema:about ?wd ;
                     schema:isPartOf <https://fr.wikipedia.org/> . }
  OPTIONAL { ?ruSite schema:about ?wd ;
                     schema:isPartOf <https://ru.wikipedia.org/> . }    
}
ORDER BY ?distance
LIMIT 100
Run it (edit query)


Find all wikidata items which have no image, i.e. which may require an illustration, near the specific osm object

#defaultView:Map
SELECT ?loc ?wd ?wdLabel ?distance ?enSite ?esSite ?deSite ?frSite ?ruSite WHERE {
 
  # for convenience, define constant parameter of the central object
  BIND (osmway:79658245 as ?osmId)
  BIND (10 as ?radius)  # in km
 
  # get object's location to use as a center of the search
  ?osmId osmm:loc ?center .

  #Wikidata does not have an Image property
  FILTER NOT EXISTS {
    ?wd wdt:P18 ?img .
  }
 
  # find all wikidata items in the close proximity
  SERVICE wikibase:around {
    ?wd wdt:P625 ?loc .
    bd:serviceParam wikibase:center ?center .
    bd:serviceParam wikibase:radius ?radius .
  }

  # Calculate distance between OSM's and WD's
  BIND(geof:distance(?center, ?loc) as ?distance)

  # For the Wikidata entry, get its label in current user's language, or in the first available
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it,pl,ru,es,sv,nl" . }

 
}
ORDER BY ?distance
LIMIT 100
Run it (edit query)