query-5aa5d632222739a605b3edfc717704c5
Searching for people with a residence within X km from a given locationHi All, I've been using the following query to find African American artists in my museum's collections who have a residence listed in their record: } } ."[AUTO_LANGUAGE],en" language:wikibase serviceParam:bd { label:wikibase SERVICE ?residence P551:wdt ;Q510324:wd P6379:wdt ;Q49085:wd P172:wdt ;Q5:wd P31:wdt ?item { WHERE ?residenceLabel ?residence ?itemDescription ?itemLabel ?item SELECT ).contribs • talk (PMAlibcat comment was added byunsignedThe preceding – I'd like to refine the results further by querying artists with a residence within an 80 km radius of Philadelphia. I'm pretty stumped on this one. Thanks in advance for the help!
Use at
- https://query.wikidata.org/sparql
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
SELECT DISTINCT
?item ?itemLabel ?itemDescription
?p ?pLabel
?coords ?distance
WHERE
{
wd:Q1345 wdt:P625 ?a0 .
SERVICE wikibase:around {
?p wdt:P625 ?coords .
bd:serviceParam wikibase:center ?a0 .
bd:serviceParam wikibase:radius "80" .
bd:serviceParam wikibase:distance ?distance .
}
?item wdt:P551 ?p .
?item wdt:P31 wd:Q5 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?distance
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?a0")
v4("?coords"):::projected
v1("?distance"):::projected
v5("?item"):::projected
v3("?p"):::projected
c4(["bd:serviceParam"]):::iri
c7(["80"]):::literal
c11(["wd:Q5"]):::iri
c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c1(["wd:Q1345"]):::iri
c1 --"wdt:P625"--> v2
subgraph s1["http://wikiba.se/ontology#around"]
style s1 stroke-width:4px;
v3 --"wdt:P625"--> v4
c4 --"wikibase:center"--> v2
c4 --"wikibase:radius"--> c7
c4 --"wikibase:distance"--> v1
end
v5 --"wdt:P551"--> v3
v5 --"wdt:P31"--> c11
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c4 --"wikibase:language"--> c14
end