query-382c7be559d06f7f73015344855e689d

rq turtle/ttl

Comunidad y ciudades autónomas de España con su densidad de población

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":["?geoshape", "?rgb"],"layer":"?label"}
SELECT ?ca ?caLabel ?poblacion ?superficie ?densidad ?rgb ?geoshape ?label WHERE {
  VALUES ?autonomia  {wd:Q10742 wd:Q16532593 wd:Q3297051}
  ?ca wdt:P31 ?autonomia ;
      wdt:P1082 ?poblacion ;
      wdt:P2046 ?superficie .
  OPTIONAL {?ca wdt:P3896 ?geoshape .}
  BIND(IF(?densidad < 50 , "ffebee", 
       IF(?densidad < 100 , "ef9a9a",
       IF(?densidad < 200 , "ef5350",
       IF(?densidad < 300 , "c62828",
       "7f0000")))) AS ?rgb)
  BIND(IF(?densidad < 50 , "Menos de 50 habs./km2", 
       IF(?densidad <= 100 , "Entre 50 y 100 habs./km2",
       IF(?densidad <=200 , "Entre 100 y 200 habs./km2",
       IF(?densidad <=300 , "Entre 200 y 300/km2",
       "Más de 300 habs./km2")))) AS ?label)  
  BIND(ROUND(?poblacion/?superficie) AS ?densidad)
  SERVICE wikibase:label {
       bd:serviceParam wikibase:language "es".
  }
} ORDER BY ?densidad

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?autonomia") v3("?ca"):::projected v9("?densidad"):::projected v6("?geoshape"):::projected v8("?label"):::projected v4("?poblacion"):::projected v7("?rgb"):::projected v5("?superficie"):::projected c6(["bd:serviceParam"]):::iri c8(["es"]):::literal bind0[/VALUES ?autonomia/] bind0-->v2 bind00(["wd:Q10742"]) bind00 --> bind0 bind01(["wd:Q16532593"]) bind01 --> bind0 bind02(["wd:Q3297051"]) bind02 --> bind0 v3 --"wdt:P31"--> v2 v3 --"wdt:P1082"--> v4 v3 --"wdt:P2046"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P3896".-> v6 end bind1[/"if(?densidad < '50^^xsd:integer','ffebee',if(?densidad < '100^^xsd:integer','ef9a9a',if(?densidad < '200^^xsd:integer','ef5350',if(?densidad < '300^^xsd:integer','c62828','7f0000'))))"/] v9 --o bind1 bind1 --as--o v7 bind2[/"if(?densidad < '50^^xsd:integer','Menos de 50 habs./km2',if(?densidad <= '100^^xsd:integer','Entre 50 y 100 habs./km2',if(?densidad <= '200^^xsd:integer','Entre 100 y 200 habs./km2',if(?densidad <= '300^^xsd:integer','Entre 200 y 300/km2','Más de 300 habs./km2'))))"/] v9 --o bind2 bind2 --as--o v8 bind3[/"numeric-round(?poblacion / ?superficie)"/] v4 --o bind3 v5 --o bind3 bind3 --as--o v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end