Samples of SPARQL Query

Get the code of Kawagoe-city and related history of changes

Query for getting the code of Kawagoe-city and related history of changes.

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX org:<http://www.w3.org/ns/org#>
PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX sac:<http://data.e-stat.go.jp/lod/sac/>
select *
where {
      ?s rdfs:label "Kawagoe-shi"@en ;
        org:resultedFrom / dcterms:description ?rfc . FILTER(LANG(?rfc)='en')
}
ORDER BY DESC(?s)

 

Get the Japanese population of Sinjuku-ward

Query for getting the Japanese population of Sinjuku-ward.

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> 
PREFIX sdmx-dimension:<http://purl.org/linked-data/sdmx/2009/dimension#>
PREFIX estat-measure:<http://data.e-stat.go.jp/lod/ontology/measure/>
PREFIX cd-dimension:<http://data.e-stat.go.jp/lod/ontology/crossDomain/dimension/> 
PREFIX cd-code:<http://data.e-stat.go.jp/lod/ontology/crossDomain/code/> 
PREFIX g00200521-dimension-2010:<http://data.e-stat.go.jp/lod/ontology/g00200521/dimension/2010/> 
PREFIX g00200521-code-2010:<http://data.e-stat.go.jp/lod/ontology/g00200521/code/2010/> 
select  ?year ?population 
where {
      ?s estat-measure:population ?population;
         sdmx-dimension:refArea / rdfs:label "Shinjuku-ku"@en ;
         cd-dimension:timePeriod ?year ; 
         cd-dimension:sex cd-code:sex-all ; 
         cd-dimension:nationality cd-code:nationality-japan ; 
         g00200521-dimension-2010:area g00200521-code-2010:area-all ; 
         cd-dimension:age cd-code:age-all . 
}

 

Get the year when statistical table of population census provides

Query for getting the year when statistical table (dataset d0003041389) which concerns population of population census.

select distinct ?o
where {
  ?s <http://purl.org/linked-data/cube#dataSet> <http://data.e-stat.go.jp/lod/dataset/g00200521/d0003041389> ;
  <http://data.e-stat.go.jp/lod/ontology/crossDomain/dimension/timePeriod>  ?o .
}

 

Get the cube model (measure, dimension and attribute) of dataset d0003041389

Query for getting the cube model (measure, dimension and attribute) of dataset d0003041389.

PREFIX qb:<http://purl.org/linked-data/cube#>
select distinct ?s
where {
<http://data.e-stat.go.jp/lod/dataset/g00200521/d0003041389/dsd> qb:component ?y.
{?y qb:dimension ?s.}
UNION
{?y qb:measure ?s.}
UNION
{?y qb:attribute ?s.}
}

 

Get the small area by specifying longitude and latitude

Query to get the small area including the point at east longitude 139.48 and north latitude 35.92.

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX ogcf: <http://www.opengis.net/def/function/geosparql/>
select ?municipality ?area
where {
      ?s <http://www.opengis.net/ont/geosparql#hasGeometry> ?polygon ;
         rdfs:label ?area ;
         dcterms:isPartOf / rdfs:label ?municipality .
      ?polygon geo:asWKT ?geom .
      FILTER (ogcf:sfContains(?geom, "POINT(139.48 35.92)"^^geo:wktLiteral)) .
      FILTER (LANG(?municipality)='ja') .
}