Data Reuse

Also available in

Data Model

Acces to the Land Library Linked Open Data Model documentation



 

SPARQL Query examples

The Land Library provides a machine interface that can enable the creation of apps based on the library data.

This interface is a SPARQL endpoint: all data can be retrieved by querying the SPARQL endpoint http://landportal.info/sparql which supports SPARQL 1.1 (http://www.w3.org/TR/sparql11-query/).

All the Land Library data are in the graph http://library.landportal.info.


Test first query and get result (html)

 

You can either write your own query or copy one of the sample queries and execute it.



Query results

 
 

 

Query examples

 

 

1. List all Land Library topics (URI and name)

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
select distinct ?TopicURI ?Name where {
 ?TopicURI a skos:Concept . 
 ?TopicURI skos:prefLabel ?Name .
 ?TopicURI skos:inScheme <http://data.landportal.info/vocabulary/5>
}

 

 

2. Get basic information (title, author, year) for each resource under topic "land reform"

You can adjust this query for any of the other topics by replacing the URI in the last line of the query with the URI of the topic (see query n.1 to get all the topics with corresponding URIs).

http://data.landportal.info/topic/fde98f54-2937-4583-9702-47cb7bb3b0f2 is the URI of the topic "land reform"

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
select distinct ?Title ?Author ?Date where {
 ?doc a bibo:Document .
 ?doc dc:title ?Title . 
 ?doc dc:creator ?auth .
 ?auth foaf:name ?Author .
 ?doc dc:date ?Date .
 ?doc dc:subject <http://data.landportal.info/topic/fde98f54-2937-4583-9702-47cb7bb3b0f2> .
}

 

 

3. Get the same data using the AGROVOC URI instead of the LP topic URI. Example for "land reform"

You can adjust this query for any of the other topics by replacing the URI in the last line of the query with the URI of the topic in AGROVOC.

http://aims.fao.org/aos/agrovoc/c_4178 is the URI of the topic "land reform" in AGROVOC

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
select distinct ?Title ?Author ?Date where {
 ?doc a bibo:Document .
 ?doc dc:title ?Title . 
 ?doc dc:creator ?auth .
 ?auth foaf:name ?Author .
 ?doc dc:date ?Date .
 ?doc dc:subject ?topic .
 ?topic owl:sameAs <http://aims.fao.org/aos/agrovoc/c_4178>
}

 

 

4. List all countries (URI and name)

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
select distinct ?CountryURI ?Name where {
 ?CountryURI a skos:Concept . 
 ?CountryURI skos:prefLabel ?Name .
 ?CountryURI skos:inScheme <http://data.landportal.info/vocabulary/3>
}

 

 

5. Get basic information (title, author, year) for each resource related to "Kenya"

You can adjust this query for any of the other topics by replacing the URI in the last line of the query with the URI of the country (see query n.3 to get all the countries with corresponding URIs).

http://data.landportal.info/country/f0792a6b-04f3-488e-a628-c8879899ed24 is the URI of the country "Kenya"

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
select distinct ?Title ?Author ?Date where {
 ?doc a bibo:Document .
 ?doc dc:title ?Title . 
 ?doc dc:creator ?auth .
 ?auth foaf:name ?Author .
 ?doc dc:date ?Date .
 ?doc dc:spatial <http://data.landportal.info/country/f0792a6b-04f3-488e-a628-c8879899ed24> .
}

 

 

6. Get the same data using the Geopolitical URI instead of the LP country URI. Example for Kenya

You can adjust this query for any of the other countries by replacing the URI in the last line of the query with the URI of the country in the Geopolitical ontology.

http://www.fao.org/countryprofiles/geoinfo/geopolitical/resource/Kenya is the URI of the country "Kenya" in the Geopolitical ontology

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
select distinct ?Title ?Author ?Date where {
 ?doc a bibo:Document .
 ?doc dc:title ?Title . 
 ?doc dc:creator ?auth .
 ?auth foaf:name ?Author .
 ?doc dc:date ?Date .
 ?doc dc:spatial ?country .
 ?country owl:sameAs <http://www.fao.org/countryprofiles/geoinfo/geopolitical/resource/Kenya>
}








 
Wordpress plugin for LandPortal Data reuse

A wordpress plugin for querying data from an SPARQL endpoint into Wordpress (developed by Open Development Mekong)



Some working examples: