User:Jheald/BL18C/queries
< User:Jheald | BL18C
Query examples[edit]
- See also tracking page
Items in class 124[edit]
SELECT ?item ?shelf ?itemLabel WHERE {
VALUES ?class_key {"124"}
?class wdt:P195 wd:Q56753539 . # KTop
?class p:P195/pq:P1545 ?class_key .
?item wdt:P195 ?class .
?item wdt:P217 ?shelf .
?item p:P195/pq:P1545 ?item_key .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?class_key ?item_key
- Version with images: link
Count of items by KTop class[edit]
SELECT (COUNT(DISTINCT(?item)) AS ?count) ?class ?classLabel ?subjectLabel WHERE {
?class p:P195 ?coll_stmt .
?coll_stmt ps:P195 wd:Q56753539 . # KTop
?coll_stmt pq:P1545 ?sort_key .
?class wdt:P921 ?subject .
?item wdt:P195 ?class .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?sort_key ?class ?classLabel ?subjectLabel
ORDER BY ?sort_key
Most prolific creators/contributors/publishers[edit]
SELECT ?count ?creator ?creatorLabel ?sample ?sampleLabel WHERE {
{
SELECT (COUNT(DISTINCT(?map)) AS ?count) ?creator (SAMPLE(?map) AS ?sample) WHERE {
?class wdt:P195 wd:Q56753539 . # KTop
?map wdt:P195 ?class .
?map (wdt:P170|wdt:P767|wdt:P123) ?creator .
} GROUP BY ?creator ?creatorLabel
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count) ?creatorLabel
Maps published furthest from their creators/contributors/publishers' birthplaces[edit]
SELECT ?dist ?creator ?creatorLabel ?pubplaceLabel ?birthplaceLabel ?map WHERE {
?class wdt:P195 wd:Q56753539 . # KTop
?map wdt:P195 ?class .
?map (wdt:P170|wdt:P767|wdt:P123) ?creator .
?creator wdt:P19 ?birthplace . ?birthplace wdt:P625 ?birthplace_coords .
?map wdt:P291 ?pubplace . ?pubplace wdt:P625 ?pubplace_coords .
BIND(geof:distance(?birthplace_coords, ?pubplace_coords) as ?dist) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?dist)
Statements with 'unmatched' as value[edit]
(none yet, in the first 10 maps)
SELECT ?map ?mapLabel ?prop WHERE {
?class wdt:P195 wd:Q56753539 . # KTop
?map wdt:P195 ?class .
?map ?prop ?val .
FILTER isBlank(?val) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Bounding box for a map[edit]
Bounding box for a single map (Q56753858).
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
#defaultView:Map{"hide":"?bbox"}
SELECT DISTINCT ?item ?itemLabel ?img ?bbox WHERE {
VALUES ?item {wd:Q56753858 }
?item p:P1332/psv:P1332/wikibase:geoLatitude ?nth .
?item p:P1333/psv:P1333/wikibase:geoLatitude ?sth .
?item p:P1334/psv:P1334/wikibase:geoLongitude ?east .
?item p:P1335/psv:P1335/wikibase:geoLongitude ?west .
OPTIONAL {?item wdt:P18 ?img} .
BIND(STRDT( CONCAT('LINESTRING (',
str(?west), ' ', str(?sth), ',',
str(?west), ' ', str(?nth), ',',
str(?east), ' ', str(?nth), ',',
str(?east), ' ', str(?sth), ',',
str(?west), ' ', str(?sth), ')' ), geo:wktLiteral) AS ?bbox) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
- Bounding boxes for all maps in the class(es) relating to South America (Q18) (i.e. KTop 124):
tinyurl.com/yb4pxmxd
. Also available multicoloured:tinyurl.com/y9njkqxa