I am using Wikidata API to get birth location from famous people, and then displaying the location using Google Maps API. Here is the Wikidata request I use :
SELECT DISTINCT ?item ?itemLabel ?birthLocation ?birthLocationLabel WHERE {
?item (wdt:P31|wdt:P101|wdt:P106)/wdt:P279* wd:Q482980 ;
rdfs:label "Mary Wollstonecraft"@en ;
wdt:P19 ?birthLocation
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
I'm then using a google geocoder to get a lat lng from the birthLocationLabel, and displaying it on the map, however sometimes the geocoder can't find a location (maybe the place doesn't exist anymore), so I'd like to know if it was possible to get coordinates from the wikidata query ? I know birth location has a "coordinate location" property, but I don't know how to access it.
Here is the link of the wikidata query
This works for me ?birthLocation wdt:P625 ?coordinates
so the whole query would be:
SELECT DISTINCT ?item ?itemLabel ?coordinates ?birthLocation ?birthLocationLabel
WHERE {
?item ((wdt:P31|wdt:P101|wdt:P106)/(wdt:P279*)) wd:Q482980;
rdfs:label "Mary Wollstonecraft"@en;
wdt:P19 ?birthLocation.
?birthLocation wdt:P625 ?coordinates.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
This returns:
[{
"item": "http://www.wikidata.org/entity/Q101638",
"itemLabel": "Mary Wollstonecraft",
"coordinates": "Point(-0.075 51.5166)",
"birthLocation": "http://www.wikidata.org/entity/Q123219",
"birthLocationLabel": "Spitalfields"
}]