query-1122ab9446355aa9a95557f4ca010f30

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?e ?i ?iLabel ?population ?area_sqkm ?areastatement WHERE {
  {
    SELECT DISTINCT ?e ?i ?r WHERE {
      VALUES ?i {
        ## List of land areas, just three for now.
        wd:Q1781 wd:Q43296 wd:Q183
      }
      OPTIONAL { ?i owl:sameAs ?r. }
      BIND(COALESCE(?r, ?i) AS ?e)
    }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  OPTIONAL { ?e wdt:P1082 ?population. }     ## Population, if it exists
  OPTIONAL {                                 ## Area, if it exists
    ?e p:P2046 ?areastatement .
    ?areastatement a wikibase:BestRank .     ## No effect.
    ##MINUS { ?e wdt:P361 wd:Q11081619 . }   ## Filter out lagoons?
    ?areastatement ps:P2046 ?area_sqkm . 
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?area_sqkm"):::projected v5("?areastatement"):::projected v3("?e"):::projected v1("?i"):::projected v4("?population"):::projected v2("?r") c3(["bd:serviceParam"]):::iri c5(["en"]):::literal c9(["wikibase:BestRank"]):::iri bind0[/VALUES ?i/] bind0-->v1 bind00(["wd:Q1781"]) bind00 --> bind0 bind01(["wd:Q43296"]) bind01 --> bind0 bind02(["wd:Q183"]) bind02 --> bind0 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."owl:sameAs".-> v2 end bind1[/"?r?i"/] v2 --o bind1 v1 --o bind1 bind1 --as--o v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c3 --"wikibase:language"--> c5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P1082".-> v4 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:P2046".-> v5 v5 --"a"--> c9 v5 --"p:statement/P2046"--> v6 end