Get WikiData Identifier for city by GPS location
Asked Answered
C

1

2

I want to get the city /settlement at a specific gps location. meaning the closest one in a given range or at best the closest.

i found some example queries in the wikimedia data examples.

I try to adopt then but i get only errors or timeouts

here is my current query:

 SELECT *
    WHERE
    {
      ?city wdt:P31/wdt:P279* wd:Q15642541 . // only settlements
       # Search by Nearest
  SERVICE wikibase:around { 
    ?place wdt:P625 ?location . 
    bd:serviceParam wikibase:center "Point(8.4024875340491 48.9993762209831)"^^geo:wktLiteral .
    bd:serviceParam wikibase:radius "1" . 
    bd:serviceParam wikibase:distance ?distance .
  }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
    } 
ORDER By ?distance

The query works when i left out the settlement condition. Butwhen i add it the query takes too long What am I doing wrong? Whats the correct syntax?

Celadon answered 23/6, 2017 at 9:39 Comment(0)
C
3

I Found my bug.

here is the working query:

 SELECT DISTINCT *
    WHERE
    {
      ?place wdt:P31/wdt:P279* wd:Q515 .
       # Search by Nearest
  SERVICE wikibase:around { 
    ?place wdt:P625 ?location . 
    bd:serviceParam wikibase:center "Point(8.4024875340491 48.9993762209831)"^^geo:wktLiteral .
    bd:serviceParam wikibase:radius "10" . 
    bd:serviceParam wikibase:distance ?distance .
  }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
    } 

Order by  ?distance
Celadon answered 23/6, 2017 at 10:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.