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:
PREFIX rdf:
PREFIX rdfs:
PREFIX owl:
PREFIX lrppi:
PREFIX skos:
PREFIX lrcommon:
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:
PREFIX rdfs:
# 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 |
=============================================================================================================================================
| | "Property type concept"@en |
---------------------------------------------------------------------------------------------------------------------------------------------
Since we now now about the type
we can ask for instances of it:
PREFIX rdf:
PREFIX rdfs:
SELECT ?x
WHERE { ?x a }
LIMIT 10
----------------------------------------------------------------
| x |
================================================================
| |
| |
| |
| |
----------------------------------------------------------------
Now we can see what's related to one of those, and by what properties. For instance
PREFIX rdf:
PREFIX rdfs:
SELECT ?x ?y
WHERE { ?x ?y }
LIMIT 10
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
| x | y |
======================================================================================================================================================================
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
and we see that the property we want is
, 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