query-4276e092b1b944f4688a9ec6c66747a8

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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 ?i ?iLabel ?population ?area_sqkm ?popstatement ?date 
WHERE
{
   { SELECT ?i (MAX(?date_) as ?date) WHERE
  {
   VALUES ?i {wd:Q884 wd:Q31057 wd:Q35555 wd:Q220982 wd:Q31063 wd:Q475038}
              ## Problematic entities with multiple population values
      OPTIONAL {                  ## Get population dates for maxing purposes
      ?i p:P1082 ?popstatement. 
      ?popstatement a wikibase:BestRank .
#      ?popstatement ps:P1082 ?population .
      ?popstatement pq:P585 ?date_ .
      }
   } GROUP BY ?i }  OPTIONAL {                  ## Population, if it exists
      ?i p:P1082 ?popstatement. 
      ?popstatement a wikibase:BestRank .
      ?popstatement ps:P1082 ?population .
      ?popstatement pq:P585 ?date .
  }
  OPTIONAL {                  ## Area, if it exists
    ?i p:P2046 ?areastatement .
    ?areastatement a wikibase:BestRank .     
    MINUS { ?areastatement pq:P518 wd:Q187223. }     ## Filter out lagoons
    MINUS { ?areastatement pq:P518 wd:Q9259. }       ## Filter out UNESCO sites
    MINUS { ?areastatement pq:P518 wd:Q64364418. }   ## Filter out buffer zones
    MINUS { ?areastatement pq:P1012 wd:Q389717. }    ## Filter out contested Islands
    ?areastatement psn:P2046/wikibase:quantityAmount ?area_norm .
    BIND( ROUND(?area_norm/1000000) as ?area_sqkm) . 
  }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} ORDER BY ASC(?iLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?area_norm") v9("?area_sqkm"):::projected v7("?areastatement") v5("?date"):::projected v4("?date_") v2("?i"):::projected v1("?iLabel"):::projected v3("?popstatement"):::projected v6("?population"):::projected a1((" ")) c3(["wikibase:BestRank"]):::iri c18(["en"]):::literal c10(["wd:Q64364418"]):::iri c8(["wd:Q187223"]):::iri c16(["bd:serviceParam"]):::iri c9(["wd:Q9259"]):::iri c12(["wd:Q389717"]):::iri bind0[/VALUES ?i/] bind0-->v2 bind00(["wd:Q884"]) bind00 --> bind0 bind01(["wd:Q31057"]) bind01 --> bind0 bind02(["wd:Q35555"]) bind02 --> bind0 bind03(["wd:Q220982"]) bind03 --> bind0 bind04(["wd:Q31063"]) bind04 --> bind0 bind05(["wd:Q475038"]) bind05 --> bind0 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:P1082".-> v3 v3 --"a"--> c3 v3 --"p:qualifier/P585"--> v4 end bind2[/"max(?date_)"/] v4 --o bind2 bind2 --as--o v5 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:P1082".-> v3 v3 --"a"--> c3 v3 --"p:statement/P1082"--> v6 v3 --"p:qualifier/P585"--> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:P2046".-> v7 v7 --"a"--> c3 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v7 --"p:qualifier/P518"--> c8 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v7 --"p:qualifier/P518"--> c9 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v7 --"p:qualifier/P518"--> c10 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v7 --"p:qualifier/P1012"--> c12 end v7 --"p:statement/value-normalized/P2046"--> a1 a1 --"wikibase:quantityAmount"--> v8 bind7[/"numeric-round(?area_norm / '1000000^^xsd:integer')"/] v8 --o bind7 bind7 --as--o v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end