query-651d85f3204f9cdbdf4a68520fc4c564
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 psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?countryLabel ?population ?area_in_m2 (?density_m2 * 1000000 AS ?density) {
?item p:P31 ?statement .
?statement ps:P31/wdt:P279* wd:Q515 .
MINUS { ?statement pq:P582 [] } .
MINUS { ?item wdt:P576 [] } .
?item wdt:P1082 ?population; p:P2046 [ a wikibase:BestRank; psn:P2046/wikibase:quantityAmount ?area_in_m2 ] .
OPTIONAL { ?item wdt:P17 ?country } .
# FILTER( ?country = wd:Q183 ) .
BIND( ?population / ?area_in_m2 AS ?density_m2 ) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
} ORDER BY DESC(?density)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?area_in_m2"):::projected
v6("?country")
v8("?density")
v7("?density_m2"):::projected
v2("?item"):::projected
v4("?population"):::projected
v3("?statement")
a2((" "))
a3((" "))
a1((" "))
a4((" "))
a5((" "))
c9(["wikibase:BestRank"]):::iri
c17(["en"]):::literal
c15(["bd:serviceParam"]):::iri
c4(["wd:Q515"]):::iri
v2 --"p:P31"--> v3
v3 --"p:statement/P31"--> a1
a1 --"p:direct/P279"--> c4
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:qualifier/P582"--> a2
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v2 --"p:direct/P576"--> a3
end
v2 --"p:direct/P1082"--> v4
a4 --"a"--> c9
a4 --"p:statement/value-normalized/P2046"--> a5
a5 --"wikibase:quantityAmount"--> v5
v2 --"p:P2046"--> a4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P17".-> v6
end
bind2[/"?population / ?area_in_m2"/]
v4 --o bind2
v5 --o bind2
bind2 --as--o v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
end
bind3[/"?density_m2 * '1000000^^xsd:integer'"/]
v7 --o bind3
bind3 --as--o v8