且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅提取邮政编码和 lsoa 代码 - sparkql

更新时间:2023-02-26 10:15:38

如果 URI 的生成方式是标准的,你可以把结果转成字符串,然后只取需要的部分:

If the way URIs are generated is standard, you can just turn the results into strings and then take only the part that is needed:

PREFIX pc: <http://data.ordnancesurvey.co.uk/ontology/postcode/>
PREFIX geo: <http://opendatacommunities.org/def/geography#>
SELECT ?postcode ?lsoa
WHERE { 
  ?URI_postcodeUnit
  a pc:PostcodeUnit;
  geo:lsoa ?URI_lsoa .
BIND (STRAFTER((STR(?URI_postcodeUnit)),"postcodeunit/") as ?postcode)
BIND (STRAFTER((STR(?URI_lsoa)),"lsoa/") as ?lsoa)
  }
  limit 10