A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/country_locations-as-topics.sparql
Country aspect: Locations as topics for a specific country
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
# title: Locations as topics for a specific country
PREFIX target: <http://www.wikidata.org/entity/Q35>
#defaultView:Map{"markercluster":true}.
SELECT
?location ?locationLabel
?work ?workLabel
?geo
?layer
WITH {
SELECT ?location ?work ?geo ?type WHERE {
?location wdt:P17 target: .
# Geocoordinates may possible be under a headquarter property
?location wdt:P159? / wdt:P625 ?geo.
?work wdt:P921 ?location .
# Filter encyclopedic articles - that may not be so relevant
FILTER NOT EXISTS { ?work wdt:P31 wd:Q17329259 }
}
} AS %results
WHERE {
INCLUDE %results
# Move here for speed of query
OPTIONAL {
?work wdt:P31 / rdfs:label ?layer .
FILTER (LANG(?layer) = 'en')
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,de,es,fr,jp,nl,no,ru,sv,zh". }
}
graph TD