Difference between revisions of "Querying the Datasets"

From Linked Earth Wiki
Jump to: navigation, search
Line 2: Line 2:
  
 
=== Semantic Media Wiki Queries ===
 
=== Semantic Media Wiki Queries ===
The data in the wiki can be queried and embedded within the wiki by Semantic Media Wiki (SMW) queries. The queries refer to the [[Special:Categories Categories]] and [[Special:Properties Properties]] defined in the wiki.
+
The data in the wiki can be queried and embedded within the wiki by Semantic Media Wiki (SMW) queries. The queries refer to the [[Special:Categories]] and [[Special:Properties]] defined in the wiki.
  
 
==== Example: Get a List of Datasets (limit to 5) ====
 
==== Example: Get a List of Datasets (limit to 5) ====
Line 62: Line 62:
 
One can also make more complex queries using SPARQL to the wiki's triple store.  The SPARQL endpoint is http://wiki.linked.earth/store/ds/query, and one can make queries by passing a query parameter with the text of the SPARQL query. The data can be returned in a variety of formats. The SPARQL queries refer to the Linked Earth core ontology terms found at http://linked.earth/ontology.  
 
One can also make more complex queries using SPARQL to the wiki's triple store.  The SPARQL endpoint is http://wiki.linked.earth/store/ds/query, and one can make queries by passing a query parameter with the text of the SPARQL query. The data can be returned in a variety of formats. The SPARQL queries refer to the Linked Earth core ontology terms found at http://linked.earth/ontology.  
  
'''Note: The mapping between terms on the wiki and the ontology can be found at any wiki Property or Category page by looking at the "Imported from" value. For example, the property [[Property:ArchivedIn_©]] imports the term core:archivedIn from the ontology, where "core:" prefix refers to the linked earth ontology at http://linked.earth/ontology'''
+
''Note: The mapping between terms on the wiki and the ontology can be found at any wiki Property or Category page by looking at the "Imported from" value. For example, the property [[Property:ArchivedIn_©]] imports the term core:archivedIn from the ontology, where "core:" prefix refers to the linked earth ontology at http://linked.earth/ontology''
  
====  ====
+
====  Get Datasets and the names of the files====
 
<pre>
 
<pre>
 +
PREFIX core: <http://linked.earth/ontology#>
 +
SELECT ?s ?pd ?table ?file
 +
WHERE {
 +
  ?s a core:Dataset .
 +
  ?s core:includesPaleoData ?pd .
 +
  ?pd core:basedOn ?proxy .
 +
  ?proxy core:name "d18O" .
 +
  ?pd core:foundInMeasurementTable ?table .
 +
  ?table core:hasFileName ?file
 +
}
 
</pre>
 
</pre>
  
 +
The following is a live URL that queries the SPARQL endpoint with the above query
 +
http://wiki.linked.earth/store/ds/query?query=PREFIX+core%3A+%3Chttp%3A%2F%2Flinked.earth%2Fontology%23%3E%0ASELECT+%3Fs+%3Fpd+%3Ftable+%3Ffile%0AWHERE+%7B%0A++%3Fs+a+core%3ADataset+.%0A++%3Fs+core%3AincludesPaleoData+%3Fpd+.%0A++%3Fpd+core%3AbasedOn+%3Fproxy+.%0A++%3Fproxy+core%3Aname+%22d18O%22+.%0A++%3Fpd+core%3AfoundInMeasurementTable+%3Ftable+.%0A++%3Ftable+core%3AhasFileName+%3Ffile%0A%7D
  
  

Revision as of 09:04, 22 June 2016

Semantic Media Wiki Queries

The data in the wiki can be queried and embedded within the wiki by Semantic Media Wiki (SMW) queries. The queries refer to the Special:Categories and Special:Properties defined in the wiki.

Example: Get a List of Datasets (limit to 5)

{{ #ask: [[Category:Dataset_©]]
 | mainlabel=Datasets
 | format=broadtable
 | limit=5
}}


Example: Get a List of Datasets that have paleo data based on d18O Proxy (limit 5)

{{ #ask: [[Category:Dataset_©]] [[IncludesPaleoData_©.BasedOn_©.Name_©::d18O]]
 | ?IncludesPaleoData_©=PaleoData
 | format=broadtable
 | limit=5
}}


Example: Get a List of Datasets with archive type "Sclerosponge" and plot them on a map

{{#ask: [[Category:Location_©]] [[CoordinatesFor.archiveType::Sclerosponge]]
 | ?Coordinates
 | ?CoordinatesFor
 | ?Name_©
 | showtitle=off
 | maxzoom=14
 | minzoom=1
 | limit=500
 | template=LiPDLocation
 | format=leaflet
}}


SPARQL Queries

One can also make more complex queries using SPARQL to the wiki's triple store. The SPARQL endpoint is http://wiki.linked.earth/store/ds/query, and one can make queries by passing a query parameter with the text of the SPARQL query. The data can be returned in a variety of formats. The SPARQL queries refer to the Linked Earth core ontology terms found at http://linked.earth/ontology.

Note: The mapping between terms on the wiki and the ontology can be found at any wiki Property or Category page by looking at the "Imported from" value. For example, the property Property:ArchivedIn_© imports the term core:archivedIn from the ontology, where "core:" prefix refers to the linked earth ontology at http://linked.earth/ontology

Get Datasets and the names of the files

PREFIX core: <http://linked.earth/ontology#>
SELECT ?s ?pd ?table ?file
WHERE {
  ?s a core:Dataset .
  ?s core:includesPaleoData ?pd .
  ?pd core:basedOn ?proxy .
  ?proxy core:name "d18O" .
  ?pd core:foundInMeasurementTable ?table .
  ?table core:hasFileName ?file
}

The following is a live URL that queries the SPARQL endpoint with the above query http://wiki.linked.earth/store/ds/query?query=PREFIX+core%3A+%3Chttp%3A%2F%2Flinked.earth%2Fontology%23%3E%0ASELECT+%3Fs+%3Fpd+%3Ftable+%3Ffile%0AWHERE+%7B%0A++%3Fs+a+core%3ADataset+.%0A++%3Fs+core%3AincludesPaleoData+%3Fpd+.%0A++%3Fpd+core%3AbasedOn+%3Fproxy+.%0A++%3Fproxy+core%3Aname+%22d18O%22+.%0A++%3Fpd+core%3AfoundInMeasurementTable+%3Ftable+.%0A++%3Ftable+core%3AhasFileName+%3Ffile%0A%7D


Querying Linked Earth Data from another Program/Script

The endpoint at http://wiki.linked.earth/store/ds/query also allows one to make queries remotely. One can make queries and get the data