Sparql 如何在wikidata中找到一个位置周围的城市?

Sparql 如何在wikidata中找到一个位置周围的城市?,sparql,wikidata,Sparql,Wikidata,我对WikiData有以下请求。它可以很好地工作,因为可以使用结果,但我想将结果限制在城市的子集(在本例中为“法国公社”) 该请求返回任何感兴趣的地方(包括并非我的意图的“Hérin”河),我需要做不同的操作,以避免与我添加的“city”建立联合 SELECT DISTINCT ?place ?placeLabel ?location WHERE { # Use the around service SERVICE wikibase:around { # Lookin

我对WikiData有以下请求。它可以很好地工作,因为可以使用结果,但我想将结果限制在城市的子集(在本例中为“法国公社”)

该请求返回任何感兴趣的地方(包括并非我的意图的“Hérin”河),我需要做不同的操作,以避免与我添加的“city”建立联合

 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
这样的人会很完美)。提前感谢您的帮助。

只需将
城市
替换为
wd:Q484170
():


因此,用
wd:Q484170
替换
?city
。也可以使用wd:Q15284(市政)代替wd:Q484170(法国公社),这是一种非常严格的限制<代码>?地点(wdt:P31/wdt:P279*)wd:Q15284
 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