Chapter 4 Applications: How can you benifit of FAIR play?

Now comes the most interesting part of the ASPAR_KR system, the usage of others data to come to a better scientific insight. In this chapter, data analysis workflows with R will be given.

4.1 The SPARQL endpoint.

Using the SPARQL endpoint

# Query to get the distance from a sample to a place.
# Returns the distance in km.
PREFIX jerm: <http://jermontology.org/ontology/JERMOntology#>
PREFIX schema: <http://schema.org/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/> 
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
SELECT ?d_km
WHERE {
    # Get the samples
    ?p ?o jerm:Sample .
    
    # Take only one specific sample.
    ?p schema:identifier ?sample_label .
    FILTER(?sample_label = "Sample_D1_a_8_8") .
    
    # Get the place
    ?p geo:hasGeometry ?geo .
    ?geo geo:asWKT ?point
    
    # Where is den Helder?
    SERVICE <https://query.wikidata.org/sparql> {
        # What things are a Dutch municipality?
        ?municipality wdt:P31 wd:Q2039348.
        # What things have a place?
        ?municipality wdt:P625 ?PlaceOfDenHelder .
        # Take only the thing that is Den Helder.
        FILTER(?municipality = wd:Q9911) .
    }
    
    # What is the distance?
    BIND (geof:distance(?point, ?PlaceOfDenHelder, 
    uom:metre) as ?dist)
    # Convert to kilo metre.
    BIND (?dist / 1000 as ?d_km)
}