sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

184

rq turtle/ttl

Topic aspect: co occurring map

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#defaultView:Map

PREFIX target: <http://www.wikidata.org/entity/Q45340488>

SELECT
  ?location ?locationLabel
  ?geo
  ?example_work ?example_workLabel
WITH {
  SELECT
    ?location ?geo
    (SAMPLE(?work) AS ?example_work)
  WHERE {
    # Find works that are marked with main subject of the topic.
    ?work wdt:P921 / ( wdt:P31*/wdt:P279* | wdt:P361+ | wdt:P1269+ ) target: .
    
    # Identify co-occuring topic that is geo-locatable. 
    ?work wdt:P921 ?location .
    ?location wdt:P625 ?geo .
  }
  GROUP BY ?location ?geo
} AS %results
WHERE {
  INCLUDE %results
  
  # Label the results
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" .
  }
}

graph TD