SPARQL Examples

The following example queries can be viewed below:

You can test these SPARQL queries at the webform at http://lobid.org/test/

Use curl with these SPARQL-Queries

Example:

Note: through "--data-urlencode" we need not to substitute i.e. a '+' with '%2B'.

Get all organisations, their URIs and their geographical coordinates

Additionally, the distance itself is requested.

Get the organisations located within a maximum distance to a specfic place

This query gets all organisations located within a circle of D = 100 km radius around a place at φ = 50.9341º in latitude and λ = 6.93549º in longitude ( a place in Cologne, Germany ).
The other numeric values in the query must be calculated from the geo-coordinates φ and λ of the observer (the "specific place"), the maximum desired distance D and a reference latitude φ 0 as follows:
φ 0 in this example was chosen to be φ 0 = 51.0º
cos(φ 0)·sin(φ 0)·π/180 = 0.00853595
cos 0)·(cos(φ 0) - sin(φ 0)·π/180·(φ -2·φ0)) = 0.831939969105
(D / brgrad) 2 = 0.808779738472242
where brgrad is the mean distance between two latitude circles, brgrad = 111.1949 km.

The variable d2brgrad in the select clause is the square of the distance of the organisation to the observer, d, divided by the square of brgrad.

The calculation in this query is an approximate one. It is only good for locations which are near to the observer point where "near" means that their distance to the observer point is small as compared to the radius of the earth, d < D << R = 6371 km . The reference latitude φ 0 must be chosen to be near the observer point where "near" has the same meaning as above. Within Germany, the approximation is good to better than 0.1% in distance.

Near the poles of the earth, the approximation is not good. For the distance in longitude must be actually also small compared to cos(φ 0R , not only to R. At the equator, cos(φ 0) = 1 and it decreases towards the poles. At φ 0 = 60º and φ 0 = -60º, we have cos(φ 0) = ½. Beyond φ 0 = 85º and φ 0 = -85º the approximation should not be used.

The returned valued d2brgrad can be transformed as follows to the distance between the organisation and the observer :

d = SQRT( d2brgrad ) * brgrad .

SPARQL cannot compute the square root, so this last step must be done by some external program.

Get the organisations located at a specific region which are holders of a specific resource

Search for libraries which are not more than 5 km away from a point in Cologne (50.9341º in latitude and 6.93549º in longitude) which have an item of the bibliographic resource http://lobid.org/resource/HT000543651.

Get the organisations located at a specific region which are holders of a resource with a specific ISBN

Search for libraries which are not more than 5 km away from a point in Cologne (50.9341º in latitude and 6.93549º in longitude) which have an item of a bibliographic resource with the ISBN "978-3-631-58937-3".

Get an item of a specific manifestation which is held by a library at a a specific region

Full text search of names of organisations

Search for organizations by organization type

In the example we search for all organization which a classified as central university libraries (see the libtype vocab for information on the underlying classification).

Get postal data and the telephonenumber (not fax) from a specific library

Get the holders of a manifestation

show me all graphs

federated search query

Querying the lobid.org database using an ISBN. The lobid.org resource has a link to dbpedia.org, and thus the dbpedia.org is queried using this link (the example is this lobid-resource). The keyword "SERVICE" enables the federated search, specified by the SPARQL-Endpoints of these "services".

Geben Sie Stichwörter ein, die dieser Seite hinzugefügt werden sollen:
Please wait 
Sie suchen ein Stichwort? Beginnen Sie einfach zu schreiben.