SPARQL examples
Some example SPARQL calls that work against the http://data.oceandrilling.org/sparql end point.
A narrative will be added to these examples (and more) soon.
Currently loaded data is also indexed at the linked data page.
# find DSDP related resources using a Freebase URI
select DISTINCT ?s
FROM <http://data.oceandrilling.org/codices#>
where {
?s ?p <http://www.freebase.com/view/en/deep_sea_drilling_program>
}
# find ODP related resources using a dbPedia URI
select DISTINCT ?s
FROM <http://data.oceandrilling.org/codices#>
where {
?s ?p <http://dbpedia.org/page/Ocean_Drilling_Program>
}
# Find log data based on geologic ages
SELECT *
FROM NAMED <http://chronos.org/timescales/>
FROM NAMED <http://data.oceandrilling.org/codices/logatage#>
WHERE {
GRAPH <http://chronos.org/timescales/> {
?s <http://chronos.org/ageName> "Paleocene" .
?s <http://chronos.org/agePrefix> "Upper" .
?s <http://chronos.org/ageMinMa> ?minma .
?s <http://chronos.org/ageMaxMa> ?maxma .
}
GRAPH <http://data.oceandrilling.org/codices/logatage#> {
?ls <http://data.oceandrilling.org/core/1/ma> ?logbottom .
}
FILTER (?logbottom > ?minma ) .
FILTER (?logbottom < ?maxma ) .
}
# list graphs
SELECT DISTINCT ?g
WHERE { GRAPH ?g { ?s ?p ?o . }
}
# Aggregates (and bif)
# the bif call makes this Virtuoso only
SELECT ?p (COUNT(DISTINCT ?o) AS ?other)
WHERE {
?s ?p ?o . ?o bif:contains '"DSDP"'
}
GROUP BY ?p
# find log file resources that also have an age model avaiable for use
PREFIX chronos: <http://www.chronos.org/loc-schema#>
PREFIX iodp: <http://data.oceandrilling.org/core/1/>
SELECT DISTINCT ?log ?agemodel ?codices ?logbottom ?lat ?long
FROM NAMED <http://data.oceandrilling.org/logdb#>
FROM NAMED <http://chronos.org/janusamp#>
WHERE {
GRAPH <http://data.oceandrilling.org/logdb#> {
?log skos:related ?codices .
?log iodp:logbottom ?logbottom .
FILTER regex(?codices, "^http://data.oceandrilling.org/codices/lsh/.*/.*/.*" ) .
}
GRAPH <http://chronos.org/janusamp#> {
?agemodel skos:related ?codices .
?agemodel geo:long ?long .
?agemodel geo:lat ?lat .
}
}
# SPARQL-geo call: find all items 1000 miles from 0,52 (lat,long)
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?m ?geo
WHERE {
?m geo:geometry ?geo .
FILTER ( <bif:st_intersects> ( ?geo, <bif:st_point> (0, 52), 1000))
}
# get some physical properties data from Janus
SELECT *
FROM <http://data.oceandrilling.org/januslod#>
WHERE {
<http://data.oceandrilling.org/januslod/parameter/tensor_core_count/306/1314#55> ?o ?p
}
# Find age models that go back at least 200 MA
PREFIX chronos: <http://www.chronos.org/loc-schema#>
SELECT ?uri ?long ?lat
FROM <http://chronos.org/janusamp#>
WHERE {
?uri chronos:age ?age .
?uri geo:long ?long .
?uri geo:lat ?lat .
OPTIONAL {
?uri chronos:age ?otherage .
FILTER (?otherage > ?age) .
} .
FILTER (!bound(?otherage))
FILTER (?age > 200)
}
# Find the relation URI that helps tie data together in the USIO graphs
PREFIX chronos: <http://www.chronos.org/loc-schema#>
SELECT ?relation
FROM <http://chronos.org/janusamp#>
WHERE {
<http://chronos.org/janusAmp/loc/agemodel/2578> skos:related ?relation .
}
# Find lith data for a given Leg Site Hole (relation)
PREFIX lithologies: <http://iodp-usio.org/core/1/lithologies/>
SELECT ?s ?top ?bottom ?mud ?sand ?gravel ?carbonate
FROM <http://dbseabed.org/#>
WHERE {
?s ?p ?o .
?s skos:related <http://oceandrilling.org/codices/lsh/122/764/A> .
?s lithologies:obsvntop ?top .
?s lithologies:obsvnbot ?bottom .
optional {
?s lithologies:mud ?mud .
?s lithologies:sand ?sand .
?s lithologies:gravel ?gravel .
?s lithologies:carbonate ?carbonate
}
FILTER (?bottom >= 40.0) .
FILTER (?top <= 50.0) .
}
PREFIX lithologies: <http://data.oceandrilling.org/core/1/lithologies/>
SELECT DISTINCT ?s ?top ?bottom ?mud ?sand ?gravel ?carbonate ?lat ?long
FROM <http://dbseabed.org/#>
WHERE {
?s ?p ?o .
?s skos:related <http://data.oceandrilling.org/codices/lsh/121> .
?s lithologies:obsvntop ?top .
?s lithologies:obsvnbot ?bottom .
?s geo:lat ?lat .
?s geo:long ?long
optional {
?s lithologies:mud ?mud .
?s lithologies:sand ?sand .
?s lithologies:gravel ?gravel .
?s lithologies:carbonate ?carbonate
}
}
ORDER BY ?top
