我对WikiData有以下请求。它可以正常使用,但我希望将结果限制为一部分城市(在这种情况下为“commune de France”)。
请求返回任何感兴趣的地方(包括河流“Hérin”,这不是我的意图),我需要做DISTINCT以避免与我添加的“城市”联合。
SELECT DISTINCT ?place ?placeLabel ?location WHERE {
# Use the around service
SERVICE wikibase:around {
# Looking for items with coordinate locations(P625)
?place wdt:P625 ?location .
# That are in a circle with a centre of with a point
bd:serviceParam wikibase:center "Point(4.8,44.32)"^^geo:wktLiteral .
# Where the circle has a radius of 20km
bd:serviceParam wikibase:radius "20" .
bd:serviceParam wikibase:distance ?distance .
} .
?place wdt:P31/wdt:P279* ?city .
# Use the label service to get the English label
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY ?distance
是否有人可以帮助我选择具有“P31”属性的地方(我认为像wdt:P31/wdt:P279* wd:Q515
这样的想法会很完美)。谢谢你的帮助。
答案 0 :(得分:2)
只需将?city
替换为wd:Q484170
(Try it here):
SELECT DISTINCT ?distance ?place ?placeLabel ?location WHERE {
# Use the around service
SERVICE wikibase:around {
# Looking for items with coordinate locations(P625)
?place wdt:P625 ?location .
# That are in a circle with a centre of with a point
bd:serviceParam wikibase:center "Point(4.8,44.32)"^^geo:wktLiteral .
# Where the circle has a radius of 20km
bd:serviceParam wikibase:radius "20" .
bd:serviceParam wikibase:distance ?distance .
} .
?place wdt:P31/wdt:P279* wd:Q484170.
# Use the label service to get the English label
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY ?distance