Project:SPARQL/examples: Difference between revisions

Line 10: Line 10:
</syntaxhighlight>
</syntaxhighlight>


== Observations within 100 km from San Francisco ==
= Federated queries =
== Plot observations based on an NCBI taxon id on Wikidata ==
<syntaxhighlight>
<syntaxhighlight>
 
#Observations and their locations
#defaultView:Map
#defaultView:Map
PREFIX wbt: <http://biodiversity.wiki.opencura.com/prop/direct/>
PREFIX wbt: <http://biodiversity.wiki.opencura.com/prop/direct/>
SELECT ?utrechtLocation
 
WHERE
SELECT * WHERE {
{
   SERVICE <https://query.wikidata.org/sparql> {
   SERVICE <https://query.wikidata.org/sparql> {
     wd:Q62 wdt:P625 ?utrechtLocation .
     ?wikidata_item p:P685/psn:P685 <http://purl.uniprot.org/taxonomy/30382> . # Get the wikidata item for the egyptian goose
   }
    }
  # Utrecht coordinates
  ?observation  wbt:P8 ?location ;                                          # Get the location of an observation
                wbt:P9 ?scientific_name_wb .                                # Get the scientific name of the observation
  ?scientific_name_wb wbt:P11 ?wikidata_item .                               # get the mapping from Wikidata for the scientific name
    
}


  SERVICE wikibase:around {
    ?observation wbt:P8 ?location .
    bd:serviceParam wikibase:center ?utrechtLocation .
    bd:serviceParam wikibase:radius "10" .
  } .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
  }
}
</syntaxhighlight>
</syntaxhighlight>
Bots, Bureaucrats, emailconfirmed, Administrators
603,740

edits