query-f9c431f225b049d245646df3fe530b62
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?barangay ?barangayLabel ?population ?lonLat ?psgc ?psgcUrl ?osmRelationUrl ?articleUrlNoRedirect WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?barangay wdt:P31 wd:Q61878 ;
wdt:P131 wd:Q405058 ;
wdt:P988 ?psgc ;
wdt:P1082 ?population ;
wdt:P625 ?lonLat ;
wdt:P402 ?osmRelId ;
BIND(IRI(CONCAT("https://psa.gov.ph/classification/psgc/?q=psgc/brgydetail/", ?psgc)) as ?psgcUrl)
BIND(IRI(CONCAT("https://www.openstreetmap.org/relation/", ?osmRelId)) as ?osmRelationUrl)
OPTIONAL {
?articleUrl schema:about ?barangay ;
schema:isPartOf <https://en.wikipedia.org/>.
BIND(IRI(CONCAT("https://en.wikipedia.org/w/index.php?&redirect=no&title=", SUBSTR(STR(?articleUrl), 31))) AS ?articleUrlNoRedirect)
}
}
ORDER BY ?psgc
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?articleUrl")
v9("?articleUrlNoRedirect"):::projected
v2("?barangay"):::projected
v4("?lonLat"):::projected
v5("?osmRelId")
v7("?osmRelationUrl"):::projected
v3("?population"):::projected
v1("?psgc"):::projected
v6("?psgcUrl"):::projected
c6(["wd:Q61878"]):::iri
c8(["wd:Q405058"]):::iri
c15([https://en.wikipedia.org/]):::iri
c2(["bd:serviceParam"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v2 --"wdt:P31"--> c6
v2 --"wdt:P131"--> c8
v2 --"wdt:P988"--> v1
v2 --"wdt:P1082"--> v3
v2 --"wdt:P625"--> v4
v2 --"wdt:P402"--> v5
bind0[/"concat('https://psa.gov.ph/classification/psgc/?q=psgc/brgydetail/',?psgc)"/]
v1 --o bind0
bind0 --as--o v6
bind1[/"concat('https://www.openstreetmap.org/relation/',?osmRelId)"/]
v5 --o bind1
bind1 --as--o v7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v8 -."schema:about".-> v2
v8 --"schema:isPartOf"--> c15
bind2[/"concat('https://en.wikipedia.org/w/index.php?&redirect=no&title=',substring(str(?articleUrl),'31^^xsd:integer'))"/]
v8 --o bind2
bind2 --as--o v9
end