HM Land Registry SPARQL邮政编码查询?

时间:2019-07-11 20:32:13

标签: sparql

我正在研究有关特定能源对房价的影响的研究。我想在产生能量的附近找到有关多个邮政编码的属性值的信息。

我发现以下有用的信息:HM Land Registry SPARQL query for multiple postcodes,并且对代码进行了明显的调整,因此我可以获得更多类别的信息。但是,只有在使用上面链接中指定的示例邮政编码时,这才产生结果。它不会为我想要的其他邮政编码返回结果。抱歉,如果有一个简单的解决方案,但是我对SPARQL(以及一般而言的编码)完全陌生。因此,我不确定下一步该怎么做?我已经附上了下面的代码。非常感谢。

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 xsd: <http://www.w3.org/2001/XMLSchema#>
prefix sr: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
prefix pc: <http://data.ordnancesurvey.co.uk/ontology/postcode/>
prefix ukhpi: <http://landregistry.data.gov.uk/def/ukhpi/>
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 DISTINCT ?regionName ?postcode ?date ?ukhpi ?volume ?ukhpi_averagePrice ?ukhpi_averagePriceCash ?ukhpi_averagePriceDetached ?ukhpi_averagePriceExistingProperty ?ukhpi_averagePriceFirstTimeBuyer ?ukhpi_averagePriceFlatMaisonette ?ukhpi_averagePriceFormerOwnerOccupier ?ukhpi_averagePriceMortgage ?ukhpi_averagePriceNewBuild ?ukhpi_averagePriceSA ?ukhpi_averagePriceSemiDetached ?ukhpi_averagePriceTerraced ?ukhpi_housePriceIndex ?ukhpi_housePriceIndexCash ?ukhpi_housePriceIndexDetached ?ukhpi_housePriceIndexExistingProperty ?ukhpi_housePriceIndexFirstTimeBuyer ?ukhpi_housePriceIndexFlatMaisonette ?ukhpi_housePriceIndexFormerOwnerOccupier ?ukhpi_housePriceIndexMortgage ?ukhpi_housePriceIndexNewBuild ?ukhpi_housePriceIndexSA ?ukhpi_housePriceIndexSemiDetached ?ukhpi_housePriceIndexTerraced ?ukhpi_percentageAnnualChange ?ukhpi_percentageAnnualChangeCash ?ukhpi_percentageAnnualChangeDetached ?ukhpi_percentageAnnualChangeExistingProperty ?ukhpi_percentageAnnualChangeFirstTimeBuyer ?ukhpi_percentageAnnualChangeFlatMaisonette ?ukhpi_percentageAnnualChangeFormerOwnerOccupier ?ukhpi_percentageAnnualChangeMortgage ?ukhpi_percentageAnnualChangeNewBuild ?ukhpi_percentageAnnualChangeSemiDetached ?ukhpi_percentageAnnualChangeTerraced ?ukhpi_percentageChange ?ukhpi_percentageChangeCash ?ukhpi_percentageChangeDetached ?ukhpi_percentageChangeExistingProperty ?ukhpi_percentageChangeFirstTimeBuyer ?ukhpi_percentageChangeFlatMaisonette ?ukhpi_percentageChangeFormerOwnerOccupier ?ukhpi_percentageChangeMortgage ?ukhpi_percentageChangeNewBuild ?ukhpi_percentageChangeSemiDetached ?ukhpi_percentageChangeTerraced ?ukhpi_refPeriodDuration ?ukhpi_refPeriodStart ?ukhpi_salesVolume ?ukhpi_salesVolumeCash ?ukhpi_salesVolumeExistingProperty ?ukhpi_salesVolumeMortgage ?ukhpi_salesVolumeNewBuild{
  SERVICE <http://data.ordnancesurvey.co.uk/datasets/os-linked-data/apis/sparql> {
    VALUES ?postcode {
      # Insert postcodes here (two example postcodes below)
      "NP20 5AW"
      "SW1W 0NY"

    }
    ?postcodeUri rdfs:label ?postcode ;
        pc:district ?ordnanceSurveyRegion .
  }

  ?region owl:sameAs ?ordnanceSurveyRegion .
  ?region rdfs:label ?regionName .
  FILTER (langMatches(lang(?regionName), "EN"))

  ?report
    ukhpi:refRegion ?region;
    ukhpi:refMonth ?date;
    ukhpi:housePriceIndex ?ukhpi.



   OPTIONAL { 
    ?report ukhpi:salesVolume ?volume
           } OPTIONAL
      { ?report  ukhpi:averagePrice  ?ukhpi_averagePrice }
    OPTIONAL
      { ?report  ukhpi:averagePriceCash  ?ukhpi_averagePriceCash }
    OPTIONAL
      { ?report  ukhpi:averagePriceDetached  ?ukhpi_averagePriceDetached }
    OPTIONAL
      { ?report  ukhpi:averagePriceExistingProperty  ?ukhpi_averagePriceExistingProperty }
    OPTIONAL
      { ?report  ukhpi:averagePriceFirstTimeBuyer  ?ukhpi_averagePriceFirstTimeBuyer }
    OPTIONAL
      { ?report  ukhpi:averagePriceFlatMaisonette  ?ukhpi_averagePriceFlatMaisonette }
    OPTIONAL
      { ?report  ukhpi:averagePriceFormerOwnerOccupier  ?ukhpi_averagePriceFormerOwnerOccupier }
    OPTIONAL
      { ?report  ukhpi:averagePriceMortgage  ?ukhpi_averagePriceMortgage }
    OPTIONAL
      { ?report  ukhpi:averagePriceNewBuild  ?ukhpi_averagePriceNewBuild }
    OPTIONAL
      { ?report  ukhpi:averagePriceSA  ?ukhpi_averagePriceSA }
    OPTIONAL
      { ?report  ukhpi:averagePriceSemiDetached  ?ukhpi_averagePriceSemiDetached }
    OPTIONAL
      { ?report  ukhpi:averagePriceTerraced  ?ukhpi_averagePriceTerraced }
    OPTIONAL
      { ?report ukhpi:housePriceIndex  ?ukhpi_housePriceIndex }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexCash  ?ukhpi_housePriceIndexCash }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexDetached  ?ukhpi_housePriceIndexDetached }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexExistingProperty  ?ukhpi_housePriceIndexExistingProperty }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexFirstTimeBuyer  ?ukhpi_housePriceIndexFirstTimeBuyer }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexFlatMaisonette  ?ukhpi_housePriceIndexFlatMaisonette }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexFormerOwnerOccupier  ?ukhpi_housePriceIndexFormerOwnerOccupier }
    OPTIONAL
      { ?report ukhpi:housePriceIndexMortgage  ?ukhpi_housePriceIndexMortgage }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexNewBuild  ?ukhpi_housePriceIndexNewBuild }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexSA  ?ukhpi_housePriceIndexSA }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexSemiDetached  ?ukhpi_housePriceIndexSemiDetached }
    OPTIONAL
      { ?report  ukhpi:housePriceIndexTerraced  ?ukhpi_housePriceIndexTerraced }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChange  ?ukhpi_percentageAnnualChange }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeCash  ?ukhpi_percentageAnnualChangeCash }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeDetached  ?ukhpi_percentageAnnualChangeDetached }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeExistingProperty  ?ukhpi_percentageAnnualChangeExistingProperty }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeFirstTimeBuyer  ?ukhpi_percentageAnnualChangeFirstTimeBuyer }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeFlatMaisonette  ?ukhpi_percentageAnnualChangeFlatMaisonette }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeFormerOwnerOccupier  ?ukhpi_percentageAnnualChangeFormerOwnerOccupier }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeMortgage  ?ukhpi_percentageAnnualChangeMortgage }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeNewBuild  ?ukhpi_percentageAnnualChangeNewBuild }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeSemiDetached  ?ukhpi_percentageAnnualChangeSemiDetached }
    OPTIONAL
      { ?report  ukhpi:percentageAnnualChangeTerraced  ?ukhpi_percentageAnnualChangeTerraced }
    OPTIONAL
      { ?report ukhpi:percentageChange  ?ukhpi_percentageChange }
    OPTIONAL
      { ?report  ukhpi:percentageChangeCash  ?ukhpi_percentageChangeCash }
    OPTIONAL
      { ?report  ukhpi:percentageChangeDetached  ?ukhpi_percentageChangeDetached }
    OPTIONAL
      { ?report ukhpi:percentageChangeExistingProperty  ?ukhpi_percentageChangeExistingProperty }
    OPTIONAL
      { ?report  ukhpi:percentageChangeFirstTimeBuyer  ?ukhpi_percentageChangeFirstTimeBuyer }
    OPTIONAL
      { ?report  ukhpi:percentageChangeFlatMaisonette  ?ukhpi_percentageChangeFlatMaisonette }
    OPTIONAL
      { ?report  ukhpi:percentageChangeFormerOwnerOccupier  ?ukhpi_percentageChangeFormerOwnerOccupier }
    OPTIONAL
      { ?report  ukhpi:percentageChangeMortgage  ?ukhpi_percentageChangeMortgage }
    OPTIONAL
      { ?report  ukhpi:percentageChangeNewBuild  ?ukhpi_percentageChangeNewBuild }
    OPTIONAL
      { ?report  ukhpi:percentageChangeSemiDetached  ?ukhpi_percentageChangeSemiDetached }
    OPTIONAL
      { ?report ukhpi:percentageChangeTerraced  ?ukhpi_percentageChangeTerraced }
    OPTIONAL
      { ?report  ukhpi:refPeriodDuration  ?ukhpi_refPeriodDuration }
    OPTIONAL
      { ?report  ukhpi:refPeriodStart  ?ukhpi_refPeriodStart }
    OPTIONAL
      { ?report  ukhpi:salesVolume  ?ukhpi_salesVolume }
    OPTIONAL
      { ?report  ukhpi:salesVolumeCash  ?ukhpi_salesVolumeCash }
    OPTIONAL
      { ?report  ukhpi:salesVolumeExistingProperty  ?ukhpi_salesVolumeExistingProperty }
    OPTIONAL
      { ?report  ukhpi:salesVolumeMortgage  ?ukhpi_salesVolumeMortgage }
    OPTIONAL
      { ?report  ukhpi:salesVolumeNewBuild  ?ukhpi_salesVolumeNewBuild }

} ORDER BY ?ukhpi_refMonth

0 个答案:

没有答案