Search code examples
sparqlopendata

Getting a list of available hierarchies from statistics.gov.scot


I'm interested in obtaining a list of available distinct hierarchies from statistics.gov.scot. The best-fit hierarchies, which I would like to list, are as follow:

http://statistics.gov.scot/def/hierarchy/best-fit#community-health-partnership
http://statistics.gov.scot/def/hierarchy/best-fit#council-area
http://statistics.gov.scot/def/hierarchy/best-fit#country

As available through API section of this sample geography.

Desired results

I would like for the desired results to return:

community-health-partnership
council-area
country

How can I construct query that would actually produce that, I can get a list of available all geographies via:

PREFIX sdmx: <http://purl.org/linked-data/sdmx/2009/dimension#>
SELECT DISTINCT ?framework 
WHERE {
    ?a sdmx:refArea ?framework .
} LIMIT 10

I was trying something on the lines:

PREFIX fits: <http://statistics.gov.scot/def/hierarchy/best-fit#>
SELECT DISTINCT ?framework 
WHERE {
    ?a fits ?framework .
} LIMIT 10

but naturally this syntax is not correct.


Solution

  • Starting on their SPARQL endpoint, you could do something like this --

    DESCRIBE <http://statistics.gov.scot/def/hierarchy/best-fit#country>
    

    Then, based on those results, you might try something like this, which results aren't exactly what you say you want, but might be better --

    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    
    SELECT  ?hierarchy
            ?label
    WHERE
      { ?hierarchy  rdfs:subPropertyOf  <http://statistics.gov.scot/def/hierarchy/best-fit>
                 ;  rdfs:label          ?label
      }