User:Stefan Kühn/SDC

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Notizen zu SDC

Allgemeines

[edit]

Statistik

[edit]

SPARQL-Abfragen auf Commons

[edit]

Bilder mit Motiv Dresden

[edit]
#------------------------------------------------------------------------------------
# Bilder mit Motiv Dresden
#------------------------------------------------------------------------------------
# defaultView:ImageGrid
SELECT ?file ?image WHERE {
  ?file wdt:P180 wd:Q1731 .
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", replace(substr(str(?url),53),"_","%20"))) AS ?image)
}

Try it!

Bilder mit Motiv Dresden und Koordinate des Aufnahmestandortes

[edit]
#------------------------------------------------------------------------------------
# Bilder mit Motiv Dresden und Koordinate des Aufnahmestandortes
#------------------------------------------------------------------------------------
#defaultView:Map, Table;ImageGrid
SELECT ?file ?image ?coordinate WHERE {
  ?file wdt:P180 wd:Q1731 .       # Motiv = Dresden
  ?file wdt:P1259 ?coordinate .   # Koordinate des Aufnahmestandortes
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", replace(substr(str(?url),53),"_","%20"))) AS ?image)
}

Try it!

Bilder im Umkreis einer Koordinate (z.B. Dresden)

[edit]
#------------------------------------------------------------------------------------
# Bilder im Umkreis einer Koordinate (z.B. Dresden)
#------------------------------------------------------------------------------------
#defaultView:Map{"hide":["?coor"]}
SELECT ?fileLabel ?fileDescription ?image ?coor
WHERE 
{
  hint:Query hint:optimizer "None".
  SERVICE <https://query.wikidata.org/sparql> { 
      wd:Q1731 wdt:P625 ?center }                     # Umkreis-Zentrum: Dresden  
  SERVICE wikibase:around {
      ?file wdt:P1259 ?coor.                        
      bd:serviceParam wikibase:center ?center . 
      bd:serviceParam wikibase:radius "1".            # Radius 1 = 1 Kilometer
  }  
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de". }
}

Try it!

Bilder ohne Motive im Umkreis einer Koordinate

[edit]
#------------------------------------------------------------------------------------
# Bilder ohne Motive im Umkreis einer Koordinate
#------------------------------------------------------------------------------------
#defaultView:Map;Table;ImageGrid
SELECT * WHERE 
{
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", replace(substr(str(?url),53),"_","%20"))) AS ?image)
  SERVICE wikibase:around {
      ?file wdt:P1259 ?coordinate.
      bd:serviceParam wikibase:center "Point(13.738361 51.049258)"^^geo:wktLiteral.
      bd:serviceParam wikibase:radius "1".                 # Radius 1 = 1 Kilometer
  } 
  MINUS {?file p:P180 [] }                                 # nur Bilder ohne Motiv 
}

Try it!

Bilder eine Nutzers auf Karte

[edit]
# Map of files authored by a Wikimedia Commons user
#TEMPLATE={"template":"Map of files authored by ?username","variables":{"?username":{"query":" SELECT DISTINCT ?username WHERE { [] p:P170/pq:P4174 ?username .} LIMIT 100"} } }
#defaultView:Map
SELECT ?file ?image ?coordinates (?date AS ?layer)  (wikibase:decodeUri(CONCAT("File:", substr(str(?url),53))) AS ?filename)
WHERE {
  BIND("Stefan Kühn" AS ?username)
  ?file (p:P170/pq:P4174) ?username;
  OPTIONAL {?file  wdt:P625|wdt:P1259 ?coordinates. }
  OPTIONAL { ?file wdt:P571 ?date. }
  # convert file into image
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)
}
LIMIT 5000

Try it!

Bilder nach Beschreibung (SDC) filtern

[edit]
# Bilder mit bestimmter SDC-Bildbeschreibung suchen
#defaultView:ImageGrid;Map;Table;
SELECT ?file ?image ?coordinate ?capiton WHERE 
{
  #?file wdt:P180 ?motiv.
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", replace(substr(str(?url),53),"_","%20"))) AS ?image)  # Dateiname

  SERVICE wikibase:around {
      ?file wdt:P1259 ?coordinate.
      bd:serviceParam wikibase:center "Point(13.738361 51.049258)"^^geo:wktLiteral.     # Zentrum  
      bd:serviceParam wikibase:radius "20".                                             # Umkreis in Kilometer (1 = 1km)
  } 
  #MINUS {?file p:P180 [] }                                                             # Bilder ohne Motive als SDC
  #OPTIONAL{ ?file schema:width ?width. }                                               # Bildbreite
  OPTIONAL{ ?file schema:caption ?capiton. }
  FILTER (CONTAINS(?capiton, '+'))                                                      # Bildbeschreibung (SDC) mit "+"
}

Try it!

Alle Eigenschaften eines Bildes

[edit]
# all properties of an image 
SELECT DISTINCT ?file ?predicate ?pLabel ?o ?oLabel
WHERE {
  VALUES ?file { sdc:M107651852 }    # an example image
{ ?file ?predicate ?o.
  BIND( IRI(REPLACE( STR(?predicate),"prop/direct/","entity/" )) AS ?p). 
}
UNION
{ ?file ?predicate1 [ ?predicate ?o ].  # qualifiers   
  BIND( IRI((REPLACE( REPLACE( STR(?predicate), "(direct/

Try it!