SPARQL Examples

Nomisma.org has implemented a SPARQL endpoint since 2013, and although the ontology and models have evolved considerably since then, it remains the core component of Nomisma’s infrastructure for aggregating data that facilitate display of related specimens, geographic visualizations, and metrical analyses in numerous external projects.

The SPARQL endpoint include the Linked Open Data representing numismatic concepts published in the Nomisma.org namespace, but also external datasets of coin types, specimens, hoards, monograms, and die links expressed as RDF in the Nomisma ontology. It is therefore possible to exploit the network of relations between these various types of entities in order to form either simple or complex queries. Some queries underlie human-usable interfaces in other projects, such as Online Coins of the Roman Empire, and these interfaces (maps showing the circulation of coins, charts depicting average weights or typological distributions, etc.) typically represent the most common research questions scholars have of the material. However, it is impossible to predict the research needs of all scholars, and the SPARQL endpoint is available to execute complicated queries. The SPARQL endpoint responds with machine-readable data, such as CSV, that can be imported into spreadsheet software, R Studio, or other platforms in order to conduct other forms of visualization.

There are some introductory materials to Nomisma.org’s online ontology, model, and SPARQL endpoint which are still largely technically relevant, such as this video below that was presented to the Dublin Core Metadata Initiative in 2015:

The SPARQL query examples cited above are listed on the Numishare blog here, stored on Gist. A wide variety of other SPARQL queries have been uploaded to Ethan Gruber’s Gist account. You can also find templates for created Nomisma RDF exports from normalized data in OpenRefine.

More recently, the Nomisma.org information system and example SPARQL queries were presented in the American Numismatic Society’s May 9, 2022 Long Table Series, Long Table 91. Data Wrangling: How to use Nomisma, recorded and available below:

A limitless number of queries can be submitted simply to interrogate Nomisma.org concepts and their relations to each other, independent of links to related coin types, hoards, or specimens aggregated by Nomisma.org. Since the minimum threshold for integrating coins from museum or archaeological collections into Nomisma.org is a link to a coin type and/or hoard URI, it is possible to make a wide variety of statistical queries about coins by means of their relationships to types, and the relationships between those types and Nomisma.org numismatic concepts and URIs that represent the concepts of symbols and monograms.

Table of Contents

Queries

List of all Roman Emperors

Get all people with a role of nm:roman_emperor and display their English preferred label.

PREFIX rdf:		<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms:		<http://purl.org/dc/terms/>
PREFIX foaf:		<http://xmlns.com/foaf/0.1/>
PREFIX nm:		<http://nomisma.org/id/>
PREFIX nmo:		<http://nomisma.org/ontology#>
PREFIX org:		<http://www.w3.org/ns/org#>
PREFIX skos:		<http://www.w3.org/2004/02/skos/core#>

SELECT ?uri ?label WHERE {
?uri a foaf:Person ;
  skos:prefLabel ?label ;
  org:hasMembership ?membership .
?membership org:role nm:roman_emperor .
FILTER(langMatches(lang(?label), "EN"))
}

All weights of Augustan denarii

This query yields all coins that have a coin type with the authority (nmo:hasAuthority) of Augustus and denomination (nmo:hasDenomination) of denarius from Roman Imperial Coinage (thus excluding provincial coinage, if applicable), and includes their weight (nmo:hasWeight). Note that the weight is required, not optional in this query.

PREFIX rdf:		<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms:		<http://purl.org/dc/terms/>
PREFIX nm:		<http://nomisma.org/id/>
PREFIX nmo:		<http://nomisma.org/ontology#>

SELECT ?type ?weight WHERE {
?type nmo:hasAuthority nm:augustus ;
  nmo:hasDenomination nm:denarius ;
  dcterms:source nm:ric.
?coin nmo:hasTypeSeriesItem ?type .
?coin nmo:hasWeight ?weight
}

Average weight of Augustan denarii

Like the query above, now we are calculating the average of all of the weights of Augustan denarii.

PREFIX rdf:		<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms:		<http://purl.org/dc/terms/>
PREFIX nm:		<http://nomisma.org/id/>
PREFIX nmo:		<http://nomisma.org/ontology#>
PREFIX xsd:		<http://www.w3.org/2001/XMLSchema#>

SELECT (AVG(xsd:decimal(?weight)) AS ?average) WHERE {
?type nmo:hasAuthority nm:augustus ;
  nmo:hasDenomination nm:denarius ;
  dcterms:source nm:ric.
?coin nmo:hasTypeSeriesItem ?type .
?coin nmo:hasWeight ?weight
}

Coins of RIC Augustus 1A and 1B

This query is similar to the query that underlies the Examples of this Type section in Numishare-based digital type corpora (see Online Coins of the Roman Empire RIC Augustus 1A, for example). The exception is that we use UNION to query for both Augustus 1A and 1B simultaneously. The query includes optional measurements and image links, as well as the numismatic collection, with a preferred language in English for that collection as provided by Nomisma.org.

PREFIX rdf:		<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms:		<http://purl.org/dc/terms/>
PREFIX nm:		<http://nomisma.org/id/>
PREFIX nmo:		<http://nomisma.org/ontology#>
PREFIX foaf:		<http://xmlns.com/foaf/0.1/>
PREFIX skos:	<http://www.w3.org/2004/02/skos/core#>

SELECT ?object ?type ?diameter ?weight ?axis ?type ?collection ?obvThumb ?revThumb ?obvRef ?revRef ?comThumb ?comRef WHERE {
	{?object nmo:hasTypeSeriesItem <http://numismatics.org/ocre/id/ric.1(2).aug.1A> }
	UNION { ?object nmo:hasTypeSeriesItem <http://numismatics.org/ocre/id/ric.1(2).aug.1B> }
	?object rdf:type nmo:NumismaticObject .
	OPTIONAL { ?object nmo:hasWeight ?weight }
	OPTIONAL { ?object nmo:hasDiameter ?diameter }
	OPTIONAL { ?object nmo:hasAxis ?axis }
	OPTIONAL { ?object dcterms:identifier ?identifier }
	OPTIONAL { ?object nmo:hasCollection ?colUri .
		?colUri skos:prefLabel ?collection FILTER(langMatches(lang(?collection), "EN"))}
	OPTIONAL { ?object foaf:thumbnail ?comThumb }
	OPTIONAL { ?object foaf:depiction ?comRef }
	OPTIONAL { ?object nmo:hasObverse ?obverse .
		?obverse foaf:thumbnail ?obvThumb }
	OPTIONAL { ?object nmo:hasObverse ?obverse .
		?obverse foaf:depiction ?obvRef }
	OPTIONAL { ?object nmo:hasReverse ?reverse .
		?reverse foaf:thumbnail ?revThumb }
	OPTIONAL { ?object nmo:hasReverse ?reverse .
		?reverse foaf:depiction ?revRef }
}

Average Diameter of RIC Augustus 1A

This query finds all coins connected to the OCRE URI for Augustus 1A and averages their diameters.

PREFIX rdf:		<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms:		<http://purl.org/dc/terms/>
PREFIX nm:		<http://nomisma.org/id/>
PREFIX nmo:		<http://nomisma.org/ontology#>
PREFIX xsd:		<http://www.w3.org/2001/XMLSchema#>

SELECT (AVG(xsd:decimal(?diameter)) AS ?average) WHERE {
?object nmo:hasTypeSeriesItem <http://numismatics.org/ocre/id/ric.1(2).aug.1A> ;
  nmo:hasDiameter ?diameter
}

All findspots for RIC Augustus 1A

This will query all coins with individual finds and all coins linked to hoards or hoards with contents containing Augustus 1A. This query makes use of the current Nomisma findspot data model (implemented April 2020). See documentation for further details. The query also searches for any subtype of Augustus 1A with the UNION query implementing the skos:broader+ property path, ?broader skos:broader+ <http://numismatics.org/ocre/id/ric.1(2).aug.1A>. In this case, there are no subtypes in Roman Imperial Coinage for Augustus 1A, but this query may be applied to other sections of RIC that do implement a subtype structure or in other hierarchically-organized type corpora, such as Seleucid Coins Online.


PREFIX rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcmitype:	<http://purl.org/dc/dcmitype/>
PREFIX dcterms:  <http://purl.org/dc/terms/>
PREFIX nm:       <http://nomisma.org/id/>
PREFIX nmo:	<http://nomisma.org/ontology#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX foaf:	<http://xmlns.com/foaf/0.1/>
PREFIX skos:      <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs:	<http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm:	<http://www.cidoc-crm.org/cidoc-crm/>

SELECT ?object ?title ?findspot ?placeName ?hoard ?hoardLabel ?lat ?long ?type ?burial WHERE {
{ ?object a nmo:NumismaticObject ;
 nmo:hasTypeSeriesItem <http://numismatics.org/ocre/id/ric.1(2).aug.1A>}
UNION { ?broader skos:broader+ <http://numismatics.org/ocre/id/ric.1(2).aug.1A> .
?object nmo:hasTypeSeriesItem ?broader ;
  a nmo:NumismaticObject }
UNION { ?contents a dcmitype:Collection ; 
  nmo:hasTypeSeriesItem <http://numismatics.org/ocre/id/ric.1(2).aug.1A> .
?object dcterms:tableOfContents ?contents }
?object dcterms:title|skos:prefLabel ?title .
{ ?object nmo:hasFindspot/crm:P7_took_place_at/crm:P89_falls_within ?findspot }
UNION { ?object dcterms:isPartOf ?hoard .
        ?hoard a nmo:Hoard ;
        skos:prefLabel ?hoardLabel ;
        nmo:hasFindspot/crm:P7_took_place_at/crm:P89_falls_within ?findspot .
   		OPTIONAL {?hoard nmo:hasClosingDate ?burial . FILTER isLiteral(?burial)}
        OPTIONAL {?hoard nmo:hasClosingDate ?closing .
                 ?closing nmo:hasEndDate ?burial}}
?findspot rdfs:label ?placeName ;
          geo:location ?loc .
?loc geo:lat ?lat ;
     geo:long ?long .
OPTIONAL { ?object rdf:type ?type FILTER (?type != skos:Concept)} 
OPTIONAL { ?object nmo:hasClosingDate ?burial . FILTER isLiteral(?burial) }}

All coins found in Northamptonshire, ordered chronologically by issue

This query uses property paths to look for children of (crm:P89_falls_within) of the Wikidata URI for Northamptonshire, England (http://www.wikidata.org/entity/Q23115).

PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX nm: <http://nomisma.org/id/>
PREFIX nmo: <http://nomisma.org/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?coin ?type ?date ?place WHERE {
?coin nmo:hasFindspot/crm:P7_took_place_at/crm:P89_falls_within ?place ;
      nmo:hasTypeSeriesItem ?type ;
      a nmo:NumismaticObject .
?place crm:P89_falls_within+ <http://www.wikidata.org/entity/Q23115> .
?type nmo:hasEndDate ?date .
} ORDER BY ASC(?date) LIMIT 100