Geospatial
Coordinates
Work with latitude and longitude coordinates in SPARQL. Learn to extract, parse, and use geographic points from Wikidata.
Coordinate Basics
Wikidata stores geographic coordinates using the WKT (Well-Known Text) format.
The main property is wdt:P625 (coordinate location), which returns
a point in the format Point(longitude latitude).
| Property | ID | Description |
|---|---|---|
| coordinate location | wdt:P625 |
Geographic coordinates (WKT point) |
Important: WKT format uses Point(longitude latitude) —
longitude comes first, which is the opposite of the common "lat, long" convention.
Basic Coordinate Queries
Get Coordinates for Programming Language Creators
#defaultView:Map
SELECT ?lang ?langLabel ?birthplace ?birthplaceLabel ?coord
WHERE {
?lang wdt:P31 wd:Q9143 ; # programming language
wdt:P178 ?developer . # developer
?developer wdt:P19 ?birthplace . # place of birth
?birthplace wdt:P625 ?coord .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
LIMIT 100
Extracting Latitude and Longitude
To extract individual latitude and longitude values, use the GeoSPARQL functions
geof:latitude and geof:longitude.
Extract Lat/Long from Coordinates
SELECT ?city ?cityLabel ?coord
(geof:latitude(?coord) AS ?lat)
(geof:longitude(?coord) AS ?long)
WHERE {
VALUES ?city {
wd:Q90 # Paris
wd:Q84 # London
wd:Q60 # New York
wd:Q1490 # Tokyo
}
?city wdt:P625 ?coord .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Cultural Heritage: Museum Locations
Major Museums with Coordinates
#defaultView:Map
SELECT ?museum ?museumLabel ?coord ?visitors
WHERE {
?museum wdt:P31/wdt:P279* wd:Q33506 ; # museum
wdt:P625 ?coord .
OPTIONAL { ?museum wdt:P1174 ?visitors . }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY DESC(?visitors)
LIMIT 200
UNESCO World Heritage Sites
#defaultView:Map
SELECT ?site ?siteLabel ?coord ?country ?countryLabel
WHERE {
?site wdt:P1435 wd:Q9259 ; # UNESCO World Heritage Site
wdt:P625 ?coord ;
wdt:P17 ?country .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Urban: City Coordinates
Capital Cities with Population
#defaultView:Map
SELECT ?city ?cityLabel ?country ?countryLabel
?coord ?population
WHERE {
?country wdt:P31 wd:Q6256 ; # country
wdt:P36 ?city . # capital
?city wdt:P625 ?coord .
OPTIONAL { ?city wdt:P1082 ?population . }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Filter Cities by Hemisphere
#defaultView:Map
SELECT ?city ?cityLabel ?coord ?lat
WHERE {
?city wdt:P31/wdt:P279* wd:Q515 ;
wdt:P1082 ?pop ;
wdt:P625 ?coord .
BIND(geof:latitude(?coord) AS ?lat)
# Southern hemisphere only (negative latitude)
FILTER(?lat < 0)
FILTER(?pop > 1000000) # Cities over 1M
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
LIMIT 100
Creating Coordinates with BIND
Create a WKT Point
SELECT ?point
WHERE {
# Create a point for Paris (longitude, latitude)
BIND("Point(2.3522 48.8566)"^^geo:wktLiteral AS ?point)
}