query-0659cd08f23209b159cbab63ff038e2b

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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT distinct ?item ?image ?label ?description ?latitude ?longitude ?nazev_obce ?nazev_okresu ?nazev_kraje ?username (group_concat(DISTINCT ?llabel; separator=", ") as ?licencni_ujednani) WHERE
{

{
  SELECT distinct ?item ?file ?image ?coord1 ?municipality1
  WHERE
  {

{
  SELECT distinct ?item ?image ?filename (sample(?coord) as ?coord1)  (sample(?municipality) as ?municipality1) ?contentUrl WHERE
  {
    SERVICE <https://query.wikidata.org/sparql>
    {

      ?item wdt:P31/wdt:P279* wd:Q1746392 .
     # works if limited only to eg. instance of: wd:Q11741382. ?item wdt:P31 wd:Q11741382. 
      ?item wdt:P17 wd:Q213 .
      ?item p:P625 ?coord . ?coord wikibase:rank ?rank filter(?rank != wikibase:DeprecatedRank) .
      ?item wdt:P18 ?image. 
      minus {?item wdt:P6736 [] .}
      ?item wdt:P131* ?municipality . ?municipality wdt:P31 wd:Q5153359 .

    }
    BIND (REPLACE(wikibase:decodeUri(SUBSTR(STR(?image), 52)), " ", "_") AS ?filename)
    BIND (REPLACE(SUBSTR(STR(?image), 52), "%20", "_") AS ?filenameUnencoded)
    BIND (MD5(?filename) AS ?MD5)
    BIND (URI(CONCAT("https://upload.wikimedia.org/wikipedia/commons/", SUBSTR(?MD5, 1, 1), "/", SUBSTR(?MD5, 1, 2), "/", ?filenameUnencoded)) As ?contentUrl)
  } group by ?item ?image ?filename ?contentUrl
}    ?file schema:contentUrl ?contentUrl .
  }
}  ?file p:P170 / pq:P4174 ?username .
  ?file wdt:P275 ?licence .
  SERVICE <https://query.wikidata.org/sparql>
          {
          ?licence rdfs:label ?llabel filter(lang(?llabel)="en") .
          ?item rdfs:label ?label filter(lang(?label)="cs") .  
          ?item schema:description ?description filter(lang(?description)="cs") .     

          ?municipality1 rdfs:label ?nazev_obce filter(lang(?nazev_obce)="cs") .  
          ?municipality1 wdt:P131* ?okres . ?okres wdt:P31 wd:Q548611 .
                      ?okres rdfs:label ?nazev_okresu filter(lang(?nazev_okresu)="cs") .  
          ?municipality1 wdt:P131* ?kraj . ?kraj wdt:P31 wd:Q38911 .
                      ?kraj rdfs:label ?nazev_kraje filter(lang(?nazev_kraje)="cs") .             

          ?coord1 psv:P625 [  
                      wikibase:geoLatitude ?latitude ;
                      wikibase:geoLongitude ?longitude ] .    

          }
} group by ?item ?image ?username ?nazev_obce ?nazev_okresu ?nazev_kraje ?label ?description ?latitude ?longitude

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?MD5") v9("?contentUrl") v3("?coord") v10("?coord1") v18("?description"):::projected v12("?file") v6("?filename") v7("?filenameUnencoded") v4("?image"):::projected v2("?item"):::projected v22("?kraj") v19("?label"):::projected v23("?latitude"):::projected v14("?licence") v25("?licencni_ujednani") v20("?llabel"):::projected v24("?longitude"):::projected v5("?municipality") v11("?municipality1") v15("?nazev_kraje"):::projected v17("?nazev_obce"):::projected v16("?nazev_okresu"):::projected v21("?okres") v1("?rank") v13("?username"):::projected a2((" ")) a1((" ")) a3((" ")) a4((" ")) c7(["wd:Q213"]):::iri c13(["wd:Q5153359"]):::iri c22(["wd:Q548611"]):::iri c5(["wd:Q1746392"]):::iri c23(["wd:Q38911"]):::iri subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; f0[["?rank != 'wikibase:DeprecatedRank'"]] f0 --> v1 v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c5 v2 --"p:direct/P17"--> c7 v2 --"p:P625"--> v3 v3 --"wikibase:rank"--> v1 v2 --"p:direct/P18"--> v4 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P6736"--> a2 end v2 --"p:direct/P131"--> v5 v5 --"p:direct/P31"--> c13 end bind2[/"replace(http://wikiba.se/ontology#decodeUri(substring(str(?image),'52^^xsd:integer')),' ','_')"/] v4 --o bind2 bind2 --as--o v6 bind3[/"replace(substring(str(?image),'52^^xsd:integer'),'%20','_')"/] v4 --o bind3 bind3 --as--o v7 bind4[/"MD5(?filename)"/] v6 --o bind4 bind4 --as--o v8 bind5[/"concat('https://upload.wikimedia.org/wikipedia/commons/',substring(?MD5,'1^^xsd:integer','1^^xsd:integer'),'/',substring(?MD5,'1^^xsd:integer','2^^xsd:integer'),'/',?filenameUnencoded)"/] v8 --o bind5 v7 --o bind5 bind5 --as--o v9 bind8[/"sample(?coord)"/] v3 --o bind8 bind8 --as--o v10 bind9[/"sample(?municipality)"/] v5 --o bind9 bind9 --as--o v11 v12 --"schema:contentUrl"--> v9 v12 --"p:P170"--> a3 a3 --"p:qualifier/P4174"--> v13 v12 --"p:direct/P275"--> v14 subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; f10[["?nazev_kraje = 'cs'"]] f10 --> v15 f11[["?nazev_okresu = 'cs'"]] f11 --> v16 f12[["?nazev_obce = 'cs'"]] f12 --> v17 f13[["?description = 'cs'"]] f13 --> v18 f14[["?label = 'cs'"]] f14 --> v19 f15[["?llabel = 'en'"]] f15 --> v20 v14 --"rdfs:label"--> v20 v2 --"rdfs:label"--> v19 v2 --"schema:description"--> v18 v11 --"rdfs:label"--> v17 v11 --"p:direct/P131"--> v21 v21 --"p:direct/P31"--> c22 v21 --"rdfs:label"--> v16 v11 --"p:direct/P131"--> v22 v22 --"p:direct/P31"--> c23 v22 --"rdfs:label"--> v15 a4 --"wikibase:geoLatitude"--> v23 a4 --"wikibase:geoLongitude"--> v24 v10 --"p:statement/value/P625"--> a4 end bind17[/"?llabel"/] v20 --o bind17 bind17 --as--o v25