I\'m trying to retrieve the type of dwelling from the UK Land Registry using a SPARQL query.
The API shows it\'s called property-types and shows there are four types: De
You just need to add the triple
?transx lrppi:propertyType ?propertytype .
to your query. For instance, here's a query based on yours:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX lrppi: <http://landregistry.data.gov.uk/def/ppi/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX lrcommon: <http://landregistry.data.gov.uk/def/common/>
SELECT ?propertytype ?paon ?saon ?street ?town ?county ?locality ?district ?postcode ?amount ?date
WHERE {
?transx lrppi:pricePaid ?amount ;
lrppi:transactionDate ?date ;
lrppi:propertyAddress ?addr ;
lrppi:propertyType ?propertytype .
?addr lrcommon:district "MALVERN HILLS"^^xsd:string .
OPTIONAL {?addr lrcommon:county ?county .}
OPTIONAL {?addr lrcommon:paon ?paon .}
OPTIONAL {?addr lrcommon:saon ?saon .}
OPTIONAL {?addr lrcommon:street ?street .}
OPTIONAL {?addr lrcommon:town ?town .}
OPTIONAL {?addr lrcommon:locality ?locality .}
OPTIONAL {?addr lrcommon:postcode ?postcode .}
}
ORDER BY ?postcode ?amount
LIMIT 10
You can copy and paste that into the endpoint and get the results. (Unfortunately, it doesn't appear that there's a way to link to the results directly.)
Here's how I found that property. The endpoint has some sample queries, one of which is ”list the RDF types in use”:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# Get labels for types used in the data.
SELECT ?type ?name
WHERE {
?type rdfs:label ?name .
FILTER EXISTS { ?something rdf:type ?type . }
}
The results of that query include
---------------------------------------------------------------------------------------------------------------------------------------------
| type | name |
=============================================================================================================================================
| <http://landregistry.data.gov.uk/def/common/PropertyTypeConcept> | "Property type concept"@en |
---------------------------------------------------------------------------------------------------------------------------------------------
Since we now now about the type <http://landregistry.data.gov.uk/def/common/PropertyTypeConcept>
we can ask for instances of it:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?x
WHERE { ?x a <http://landregistry.data.gov.uk/def/common/PropertyTypeConcept> }
LIMIT 10
----------------------------------------------------------------
| x |
================================================================
| <http://landregistry.data.gov.uk/def/common/detached> |
| <http://landregistry.data.gov.uk/def/common/semi-detached> |
| <http://landregistry.data.gov.uk/def/common/flat-maisonette> |
| <http://landregistry.data.gov.uk/def/common/terraced> |
----------------------------------------------------------------
Now we can see what's related to one of those, and by what properties. For instance
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?x ?y
WHERE { ?x ?y <http://landregistry.data.gov.uk/def/common/detached> }
LIMIT 10
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
| x | y |
======================================================================================================================================================================
| <http://landregistry.data.gov.uk/data/ppi/transaction/C7AE071D-242D-4825-9162-97BBF3B71840/2009-02-27233> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/D0CDBC03-5147-4D93-BCE5-176AF007E391/2009-02-10191> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/E37CAA33-CEF5-4162-8E07-918394B3C8AF/2009-02-00643> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/E37CAA33-CEF5-4162-8E07-918394B3C8AF/2009-03-32825> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/22276002-0030-4748-A7F6-C20F125DAC1C/2009-02-47264> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/FA525F65-CC8E-4617-A682-F8B267319445/2009-02-38989> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/3BFA438C-47AE-4B47-87AD-5DC365977619/2009-02-37729> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/A5BED22B-F54B-4459-9BF9-18920B8CDBAA/2009-02-21721> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/DDAAE7E0-B07F-49FF-AAB6-A2B96D8D4DE3/2009-02-11020> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/5168D986-FAA2-42E8-B2C8-A04981C8BD0F/2009-02-09080> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
and we see that the property we want is <http://landregistry.data.gov.uk/def/ppi/propertyType>
, which can be shortened to lrppi:propertyType
using the prefixes that you have defined. It seems to relate transactions to property types, and since the transaction in your query was ?transx
, we add
?transx lrppi:propertyType ?propertyType
You may be interested in some other ways of accessing the Land Registry data that may also help you see more of the data model behind it.
[As a Stack Overflow newbie - I only get to post two links - with a higher reputation (>10) I could give more pointers :-) for now I'll give some pointer relative to landregistry.data.gov.uk]
In terms of the 'question' embedded in the query above, you'll find that:
will start to list transaction records associated with properties that have an address in the Malvern Hills district - and show the detail of both the record and the address.
On the top right of the page that results, you'll see some links for .json, .csv, .rdf and .ttl alternative renderings.
There is also a 'bunch' of controls on the page that enable you to do some property based querying (more-like-this links, less-than and greater-than links on numeric properties). To the right there are some 'sort' selectors that you should use with care - ordering a large population of items can be slow, rather than accepting the natural order that results arise.
Clicking the various controls builds up more parameters in the request URI which is the real interface to the data. The machinery here is a thing called the linked-data api (really a framework for creating URI driven interfaces onto SPARQL datasets than a concrete api - see https://code.google.com/p/elda/ which is LDA the implementation deployed in this case).
You'll also see the underlying SPARQL queries used generate the results at the foot of the html pages.
You should find you can click on all the property names and class names to retrieve their definitions: eg:
To explore the vocabularies/data models, you can trim back the class name to:
and you'll get a list of terms (properties and classes) in the ppi (price-paid information) vocabulary. Trim back even further to:
and you'll get a list of vocabularies.
For class terms
For list of URI patterns served by the LDA installation... take a look at
Also... just to get started, for the moral equivalent of 'My First SPARQL query' ie.
Try:
note that you can add URI &{P}={V} filters to be more selective.