CINXE.COM
Nomisma.org SPARQL Examples
<!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"></meta> <meta name="viewport" content="width=device-width, initial-scale=1"></meta> <title>Nomisma.org SPARQL Examples</title> <link rel="icon" type="image/svg+xml" href="/images/favicon.svg"></link> <script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script> <!-- bootstrap --> <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></link> <script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <link rel="stylesheet" href="/css/style.css"></link> <link type="text/css" rel="stylesheet" href="/css/prism.css"></link> <script type="text/javascript" src="/javascript/prism.js"></script> <!-- Begin Jekyll SEO tag v2.7.1 --> <title>Nomisma.org SPARQL Examples | Nomisma.org</title> <meta name="generator" content="Jekyll v4.2.0" /> <meta property="og:title" content="Nomisma.org SPARQL Examples" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="Nomisma.org is a collaborative project to provide stable digital representations of numismatic concepts according to the principles of Linked Open Data." /> <meta property="og:description" content="Nomisma.org is a collaborative project to provide stable digital representations of numismatic concepts according to the principles of Linked Open Data." /> <link rel="canonical" href="http://nomisma.org/documentation/sparql/" /> <meta property="og:url" content="http://nomisma.org/documentation/sparql/" /> <meta property="og:site_name" content="Nomisma.org" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="Nomisma.org SPARQL Examples" /> <script type="application/ld+json"> {"@type":"WebPage","url":"http://nomisma.org/documentation/sparql/","headline":"Nomisma.org SPARQL Examples","description":"Nomisma.org is a collaborative project to provide stable digital representations of numismatic concepts according to the principles of Linked Open Data.","@context":"https://schema.org"}</script> <!-- End Jekyll SEO tag --> </head> <body> <div class="navbar navbar-default navbar-static-top" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"/> <span class="icon-bar"/> <span class="icon-bar"/> </button> <a class="navbar-brand logo-nav" href="/"> <img style="height: 32px;" src="/images/nomisma-horizontal.svg" alt="nomisma.org"/> </a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li> <a href="/browse">Browse IDs</a> </li> <li> <a href="/about">About</a> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Who We Are <b class="caret"></b></a> <ul class="dropdown-menu"> <li> <a href="/about/scientific_committee">Scientific Committee</a> </li> <li> <a href="/about/working_groups">Working Groups</a> </li> <li> <a href="/editor/">Editors</a> </li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Research Tools <b class="caret"></b></a> <ul class="dropdown-menu"> <li> <a href="/research/distribution">Typological Distribution</a> </li> <li> <a href="/research/metrical">Measurement Analysis</a> </li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a> <ul class="dropdown-menu"> <li> <a href="/ontology">Ontology</a> </li> <li> <a href="https://nomisma.hypotheses.org/the-nomisma-org-cookbook">Cookbook</a> </li> <li> <a href="/nuds">Numismatic Description Schema (NUDS)</a> </li> <li> <a href="/documentation/apis">APIs</a> </li> <li> <a href="/documentation/contribute">Contribute Data</a> </li> <li> <a href="https://www.zotero.org/groups/4411268/digital_numismatics">Digital Numismatics Bibliography</a> </li> <li> <a href="/documentation/sparql">SPARQL Examples</a> </li> </ul> </li> <li> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Get Data <b class="caret"></b></a> <ul class="dropdown-menu"> <li> <a href="/data">Overview</a> </li> <li> <a href="/datasets">Partner Datasets</a> </li> <li> <a href="/sparql">SPARQL</a> </li> </ul> </li> </ul> <div class="col-sm-3 col-md-3 pull-right"> <form class="navbar-form" role="search" action="/browse" method="get"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search IDs" name="q" id="srch-term"></input> <div class="input-group-btn"> <button class="btn btn-default" type="submit"> <i class="glyphicon glyphicon-search"></i> </button> </div> </div> </form> </div> </div> </div> </div> <div class="container-fluid content"> <div class="row"> <div class="col-md-12"> <h1 id="sparql-examples">SPARQL Examples</h1> <p>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鈥檚 infrastructure for aggregating data that facilitate display of related specimens, geographic visualizations, and metrical analyses in numerous external projects.</p> <p>The SPARQL endpoint include the Linked Open Data representing numismatic concepts published in the Nomisma.org namespace, but also external <a href="/datasets">datasets</a> of coin types, specimens, hoards, monograms, and die links expressed as RDF in the Nomisma <a href="/ontology">ontology</a>. 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 <a href="http://numismatics.org/ocre">Online Coins of the Roman Empire</a>, 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.</p> <p>There are some introductory materials to Nomisma.org鈥檚 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:</p> <div class="text-center"> <iframe width="560" height="315" src="https://www.youtube.com/embed/3YhG5QQmhvU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div> <p>The SPARQL query examples cited above are listed on the Numishare blog <a href="https://numishare.blogspot.com/2015/05/sparql-examples-for-dcmiasis-webinar.html">here</a>, stored on Gist. A wide variety of other SPARQL queries have been uploaded to Ethan Gruber鈥檚 <a href="https://gist.github.com/ewg118/">Gist account</a>. You can also find templates for created Nomisma RDF exports from normalized data in OpenRefine.</p> <p>More recently, the Nomisma.org information system and example SPARQL queries were presented in the American Numismatic Society鈥檚 May 9, 2022 Long Table Series, <em>Long Table 91. Data Wrangling: How to use Nomisma</em>, recorded and available below:</p> <div class="text-center"> <iframe width="560" height="315" src="https://www.youtube.com/embed/0_2FrxfM3d0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div> <p>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.</p> <h2 id="table-of-contents">Table of Contents</h2> <ul> <li> <p><a href="#list-roman-emperors">List of all Roman Emperors</a></p> </li> <li> <p><a href="#augustan-weights">All weights of Augustan denarii</a></p> </li> <li> <p><a href="#augustan-avg-weight">Average weight of Augustan denarii</a></p> </li> <li> <p><a href="#augustus-1a-ab">Coins of RIC Augustus 1A and 1B</a></p> </li> <li> <p><a href="#augustus-1a-diameter">Average Diameter of RIC Augustus 1A</a></p> </li> <li> <p><a href="#augustus-1a-findspots">All findspots for RIC Augustus 1A</a></p> </li> <li> <p><a href="#geographic-hierarchy">All coins found in Northamptonshire, ordered chronologically by issue</a></p> </li> </ul> <h2 id="queries">Queries</h2> <h3 id="list-roman-emperors">List of all Roman Emperors</h3> <p>Get all people with a role of <code class="language-plaintext highlighter-rouge">nm:roman_emperor</code> and display their English preferred label.</p> <pre><code class="language-sparql">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")) } </code></pre> <h3 id="augustan-weights">All weights of Augustan denarii</h3> <p>This query yields all coins that have a coin type with the authority (<code class="language-plaintext highlighter-rouge">nmo:hasAuthority</code>) of Augustus and denomination (<code class="language-plaintext highlighter-rouge">nmo:hasDenomination</code>) of denarius from <em>Roman Imperial Coinage</em> (thus excluding provincial coinage, if applicable), and includes their weight (<code class="language-plaintext highlighter-rouge">nmo:hasWeight</code>). Note that the weight is <em>required</em>, not optional in this query.</p> <pre><code class="language-sparql">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 } </code></pre> <h3 id="augustan-avg-weight">Average weight of Augustan denarii</h3> <p>Like the query above, now we are calculating the average of all of the weights of Augustan denarii.</p> <pre><code class="language-sparql">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 } </code></pre> <h3 id="augustus-1a-ab">Coins of RIC Augustus 1A and 1B</h3> <p>This query is similar to the query that underlies the <strong>Examples of this Type</strong> section in Numishare-based digital type corpora (see Online Coins of the Roman Empire <a href="http://numismatics.org/ocre/id/ric.1(2).aug.1A">RIC Augustus 1A</a>, 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.</p> <pre><code class="language-sparql">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 } } </code></pre> <h3 id="augustus-1a-diameter">Average Diameter of RIC Augustus 1A</h3> <p>This query finds all coins connected to the OCRE URI for Augustus 1A and averages their diameters.</p> <pre><code class="language-sparql">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 } </code></pre> <h3 id="augustus-1a-findspots">All findspots for RIC Augustus 1A</h3> <p>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 <a href="/documentation/contribute#findspot">documentation</a> for further details. The query also searches for any subtype of Augustus 1A with the UNION query implementing the <code class="language-plaintext highlighter-rouge">skos:broader+</code> property path, <code class="language-plaintext highlighter-rouge">?broader skos:broader+ <http://numismatics.org/ocre/id/ric.1(2).aug.1A></code>. In this case, there are no subtypes in <em>Roman Imperial Coinage</em> 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 <a href="http://numismatics.org/sco/">Seleucid Coins Online</a>.</p> <pre><code class="language-sparql"> 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) }} </code></pre> <h3 id="geographic-hierarchy">All coins found in Northamptonshire, ordered chronologically by issue</h3> <p>This query uses property paths to look for children of (<code class="language-plaintext highlighter-rouge">crm:P89_falls_within</code>) of the Wikidata URI for Northamptonshire, England (<a href="http://www.wikidata.org/entity/Q23115">http://www.wikidata.org/entity/Q23115</a>).</p> <pre><code class="language-sparql">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 </code></pre> </div> </div> </div> <div id="footer"> <div class="container-fluid"> <p><a href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/88x31.png"/></a><br/>Unless specified otherwise, content in <a href="http://nomisma.org" xmlns:dc="http://purl.org/dc/elements/1.1/">Nomisma.org</a> is licensed under a <a xmlns:cc="http://creativecommons.org/ns#" href="http://creativecommons.org/licenses/by/3.0/" >Creative Commons Attribution 3.0 License</a>.</p> <p>Please support Nomisma.org by <a href="https://numismatics.org/giving/">Giving to the American Numismatic Society</a>.</p> </div> </div> </body> </html>