rdfabout.net: Resource Description Framework
Census Dataset SPARQL Query Page

On this page you can try out the SPARQL queries against the Census RDF dataset hosted here. Examples are below.

The SPARQL engine's base URL for SPARQL-enabled applications is http://www.rdfabout.com/sparql. The SPARQL engine is Ryan Levering's engine for SESAME, plus my SemWeb library for C#. The data store is persisted in MySQL.

Enter a SPARQL query below:

Display As:

Useful Namespaces

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>
PREFIX dcterms:  <http://purl.org/dc/terms/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>

PREFIX usgov: <http://www.rdfabout.com/rdf/schema/usgovt/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX census1: <tag:govshare.info,2005:rdf/census/details/100pct/>
PREFIX census2: <tag:govshare.info,2005:rdf/census/details/samp/>

Example Queries

Try out these examples:

List the counties in New York sorted by the median income of the county:

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>
PREFIX dcterms:  <http://purl.org/dc/terms/>
PREFIX usgov: <http://www.rdfabout.com/rdf/schema/usgovt/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX census2: <tag:govshare.info,2005:rdf/census/details/samp/>

SELECT ?name ?medianincome WHERE {
  ?county dcterms:isPartOf <http://www.rdfabout.com/rdf/usgov/geo/us/ny> ;
  rdf:type usgov:County ;
  dc:title ?name .
  ?county census:details [
    census2:population15YearsAndOverWithIncomeIn1999 [
      census2:medianIncomeIn1999 ?medianincome
    ]
  ] .
} ORDER BY ?medianincome

List the states in the United States that have more students in dorms than prisoners:

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>
PREFIX usgov: <http://www.rdfabout.com/rdf/schema/usgovt/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX census1: <tag:govshare.info,2005:rdf/census/details/100pct/>

SELECT ?name ?prisoners ?students WHERE {
  ?state rdf:type usgov:State ;
  dc:title ?name .
  ?state census:details [
    census1:populationInGroupQuarters [
      census1:institutionalizedPopulation [
        census1:correctionalInstitutions ?prisoners
      ] ;
      census1:noninstitutionalizedPopulation [
       census1:collegeDormitories__includesCollegeQuartersOffCampus ?students
      ]
    ]
  ] .
  FILTER(?students > ?prisoners) .
}

Get a list of all "universe" predicates: (Universes are described in the data document linked above.)

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?universe WHERE {
   ?universe rdf:type <tag:govshare.info,2005:rdf/census/Universe> .
}

See how a universe predicate or any other census details predicate is subdivided:

DESCRIBE <tag:govshare.info,2005:rdf/census/details/samp/population16To19Years>
This site is run by Joshua Tauberer.