rdf - How to access the Land Registry dwelling type from a SPARQL query -
i'm trying retrieve type of dwelling uk land registry using sparql query.
the api shows it's called property-types , shows there 4 types: detached, flat-maisonette, semi-detached, terraced. api here: http://landregistry.data.gov.uk/def/common?_page=1.
the query is:
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 { service <http://landregistry.data.gov.uk/landregistry/sparql> { ?transx lrppi:pricepaid ?amount . ?transx lrppi:transactiondate ?date . ?transx lrppi:propertyaddress ?addr. ?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 ?postcode ?amount limit 1000
this retrieves data i'm expecting (limited 1000 speed), i'd pull out data showing whether it's detached, terraced etc.
any appreciated!
the answer
you need add triple
?transx lrppi:propertytype ?propertytype .
to query. instance, here's 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 { ?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 ?postcode ?amount limit 10
you can copy , paste the endpoint , results. (unfortunately, doesn't appear there's way link results directly.)
finding answer
here's how found property. endpoint has sample queries, 1 of ”list 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#> # labels types used in data. select ?type ?name { ?type rdfs:label ?name . filter exists { ?something rdf:type ?type . } }
the results of query include
--------------------------------------------------------------------------------------------------------------------------------------------- | type | name | ============================================================================================================================================= | <http://landregistry.data.gov.uk/def/common/propertytypeconcept> | "property type concept"@en | ---------------------------------------------------------------------------------------------------------------------------------------------
since type <http://landregistry.data.gov.uk/def/common/propertytypeconcept>
can ask 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 { ?x <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 can see what's related 1 of those, , properties. 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 { ?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 see property want <http://landregistry.data.gov.uk/def/ppi/propertytype>
, can shortened lrppi:propertytype
using prefixes have defined. seems relate transactions property types, , since transaction in query ?transx
, add
?transx lrppi:propertytype ?propertytype
Comments
Post a Comment