About: Home

GeoSpecies Example SPARQL Queries

Introduction

Below are four SPARQL examples queries that work on the GeoSpecies Data Set.

These can be run from a query page on your own local triple store, the LOD Query page or via a third party SPARQL query application.

The query results below include examples from both a local triplestore and the LOD SPARQL query interface.

Advantages

Three key differences between this representation is and those of data silo's that expose views via a web interface are:

  1. The RDF data is available as a free open download.
  2. The data is interlinked with billions of other facts as part of the Linked Open Data Cloud.
  3. The interlinking allows queries and machine analysis of relationships between any of the other data sets in the cloud.
Examples
  1. Mosquitoes (Culicidae) Expected in Wisconsin
  2. Owls in the family Strigidae that are expected in Wisconsin
  3. Species with Observation records in Door County, Wisconsin
  4. Species in GeoSpecies Knowledge Base that have BBC Species Pages
  5. Query for USDA Plants in a Wisconsin County
  6. Query for USDA "Trees" in Michigan
  7. Query for Bats (Chiroptera) that are expected in the UK
  8. Mosquito Species in which West Nile Virus has been detected that are also known to occur in Iowa

These can be pasted into the LOD query text window at http://lod.openlinksw.com/sparql, or queried from your own triple store. All are based on the records in the GeoSpecies Knowledge Base.


LOD SPARQL Query Screen

1) Mosquitoes (Culicidae) Expected in Wisconsin


PREFIX geospecies: <http://rdf.geospecies.org/ont/geospecies#>
PREFIX culicidae:  <http://lod.geospecies.org/families/wQViY>
PREFIX wisconsin:  <http://sws.geonames.org/5279468/>
PREFIX dcterms:    <http://purl.org/dc/terms/>

SELECT DISTINCT ?family_name ?canonicalName ?speciesconcept ?geospeciespage

WHERE {
?x geospecies:hasFamilyName ?family_name;
 geospecies:hasCanonicalName ?canonicalName;
 dcterms:identifier ?speciesconcept;
 geospecies:hasGeoSpeciesPage ?geospeciespage;
 geospecies:inFamily culicidae:;
 geospecies:isExpectedIn wisconsin:.
}
ORDER BY ?family_name ?canonicalName

Truncated Example Output:

Wisconsin Mosquito Query Result

2) Owls in the family Strigidae that are Expected in Wisconsin


PREFIX geospecies:  <http://rdf.geospecies.org/ont/geospecies#>
PREFIX strigidae:   <http://lod.geospecies.org/families/a4vTG>
PREFIX wisconsin:   <http://sws.geonames.org/5279468/>
PREFIX dcterms:     <http://purl.org/dc/terms/>

SELECT DISTINCT ?family_name ?canonicalName ?speciesconcept ?geospeciespage

WHERE {
?x geospecies:hasFamilyName ?family_name;
  geospecies:hasCanonicalName ?canonicalName;
  dcterms:identifier ?speciesconcept;
  geospecies:hasGeoSpeciesPage ?geospeciespage;
  geospecies:inFamily strigidae:;
  geospecies:isExpectedIn wisconsin:.
}
ORDER BY ?family_name ?canonicalName

Example Output:

Wisconsin Owl Species Query Result

3) Species with Observation records in Door County, Wisconsin


PREFIX geospecies:  <http://rdf.geospecies.org/ont/geospecies#>
PREFIX door_county: <http://sws.geonames.org/5250768/>
PREFIX dcterms:     <http://purl.org/dc/terms/>

SELECT DISTINCT ?family_name ?canonicalName ?speciesconcept ?geospeciespage

WHERE {
?x geospecies:hasFamilyName ?family_name;
 geospecies:hasCanonicalName ?canonicalName;
 dcterms:identifier ?speciesconcept;
 geospecies:hasGeoSpeciesPage ?geospeciespage;
 geospecies:wasObservedIn door_county:.
}
ORDER BY ?family_name ?canonicalName

Example Output:

Door County Observation Query Result

4) Species in GeoSpecies Knowledge Base that have BBC Species Pages

At this time only some of the species with BBC Species pages are linked via the GeoSpecies Knowledge base. This query returns a list of those species and the BBC URL.


PREFIX geospecies: <http://rdf.geospecies.org/ont/geospecies#>


SELECT DISTINCT ?FamilyName ?CanonicalName ?BBCpage

WHERE {
?x geospecies:hasFamilyName ?FamilyName;
 geospecies:hasCanonicalName ?CanonicalName;
 geospecies:hasBBCPage ?BBCpage.
}
ORDER BY ?FamilyName ?CanonicalName

Example Output:

BBC Query Result

5) Query for USDA Plants in a Wisconsin County

The GeoSpecies Knowledge Base currently containts USDA Plants county level records for all of the counties in Wisconsin. You can query for plants by county and taxonomic group. In the example below is for a query of plants within the Phylum Lycopodiophyta (Club Mosses, Spikemosses and Quillworts) that the USDA Plants database indicates are in Door County, Wisconsin. This example uses the 'Optional' keyword so that those species that don't have a common name or a Wikipedia page will still be displayed. I also used a new predicate "geospecies:isUSDAExpectedin", to keep these assertions separate from those made by other data sets, since they are likely to return different results. This also makes it possible to compare lists from the USDA data set to lists from other sources like the Wisconsin Herbarium.


PREFIX geospecies:     <http://rdf.geospecies.org/ont/geospecies#>
PREFIX lycopodiophyta: <http://lod.geospecies.org/phyla/Pc2>
PREFIX door_county:    <http://sws.geonames.org/5250768/>
PREFIX dcterms:        <http://purl.org/dc/terms/>

SELECT DISTINCT ?family_name ?canonicalName ?commonName ?identifier ?wikipedia_url

WHERE {
?x geospecies:hasFamilyName ?family_name;
   geospecies:hasCanonicalName ?canonicalName;
   geospecies:hasCommonName ?commonName;
   dcterms:identifier ?identifier;
   geospecies:inPhylum lycopodiophyta:;
   geospecies:isUSDA_ExpectedIn door_county:.
   OPTIONAL { ?x  geospecies:hasCommonName  ?commonName;
                  geospecies:hasWikipediaArticle ?wikipedia_url}
     }

   ORDER BY ?family_name ?canonicalName

Example Output:

USDA Plants Door County Query Result

6) Query for Trees in Michigan

The GeoSpecies Knowledge Base currently contains USDA Plants state level records for Iowa, Michigan, Minnesota and Wisconsin. You can query for plants by state, taxonomic group and USDA Growth Form. The example below is for a query of species with the USDA Growth form "Tree" that the USDA data indicates are expected in Michigan. This example uses the 'Optional' keyword so that those species that don't have a common name or a Wikipedia page will still be displayed.


PREFIX geospecies:     <http://rdf.geospecies.org/ont/geospecies#>
PREFIX tree:           <http://rdf.geospecies.org/ont/geospecies#USDA_Growth_Habit_Tree>
PREFIX rdf:            <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX michigan:       <http://sws.geonames.org/5001836/>
PREFIX dcterms:        <http://purl.org/dc/terms/>

SELECT DISTINCT ?family_name ?canonicalName ?commonName ?identifier ?wikipedia_url

WHERE {
?x geospecies:hasFamilyName ?family_name;
   geospecies:hasCanonicalName ?canonicalName;
   geospecies:hasCommonName ?commonName;
   dcterms:identifier ?identifier;
   rdf:type tree:;
   geospecies:isUSDA_ExpectedIn michigan:.
   OPTIONAL { ?x  geospecies:hasCommonName  ?commonName;
                  geospecies:hasWikipediaArticle ?wikipedia_url}
     }

   ORDER BY ?family_name ?canonicalName

Example Output: (Partial Listing)

USDA Plants Door County Query Result

7) Bats (Chiroptera) in the UK

The GeoSpecies Knowledge Base currently contains the Mammals expected in the UK. The example below is for a query of species in the order Chiroptera that are are expected in the UK.


PREFIX geospecies:     <http://rdf.geospecies.org/ont/geospecies#>
PREFIX uk:             <http://sws.geonames.org/2635167/>
PREFIX bats:           <http://lod.geospecies.org/orders/TuTld>
PREFIX dcterms:        <http://purl.org/dc/terms/>

SELECT DISTINCT ?family_name ?canonicalName ?speciesconcept ?geospeciespage

WHERE {
?x geospecies:hasFamilyName ?family_name;
 geospecies:hasCanonicalName ?canonicalName;
 dcterms:identifier ?speciesconcept;
 geospecies:hasGeoSpeciesPage ?geospeciespage;
 geospecies:inOrder bats:;
 geospecies:isExpectedIn uk:.
}
ORDER BY ?family_name ?canonicalName

Example Output:

UK Bats Query Result

8) Mosquito Species in which West Nile Virus has been detected that are also known to occur in Iowa

Not all mosquitoes can transmit West Nile Virus. It is not clear which mosquitoes are actual vectors of West Nile Virus to humans. This query returns the list of those species in which West Nile Virus has been detected that are also known to occur in Iowa. This makes these species potential vectors, but not necessarily known vectors of West Nile Virus. See CDC: West Nile Virus - Mosquito Species.


PREFIX geospecies:        <http://rdf.geospecies.org/ont/geospecies#>
PREFIX mosquito:          <http://rdf.geospecies.org/ont/families/wQViY/wQViY_ontology.owl#>
PREFIX iowa:              <http://sws.geonames.org/4862182/>
PREFIX west_nile_virus:   <http://lod.geospecies.org/ses/2M8Wk>

SELECT DISTINCT ?scientific_name ?commonName ?wikipedia_url ?bugguide_url

WHERE {
?x geospecies:hasScientificName ?scientific_name;
 mosquito:isPossibleMosquitoVectorOfVirus west_nile_virus:;
 geospecies:isExpectedIn iowa:.
 OPTIONAL { ?x  geospecies:hasCommonName             ?commonName;
                geospecies:hasWikipediaArticle       ?wikipedia_url;
                geospecies:hasBugGuidePage           ?bugguide_url}

}
ORDER BY ?scientific_name

Example Output:

Potential Mosquito Vectors of West Nile Virus Expected in Iowa

Creative Commons License
GeoSpecies Knowledge Base by Peter J. DeVries