Domain Chapter

Geospatial Queries

Query the world with location-based SPARQL. Work with coordinates, calculate distances, filter by regions, and visualize results on interactive maps using Wikidata's rich geographic data.

5
Topics
Maps
Visualization
Intermediate
Level

Location Data in Knowledge Graphs

Wikidata contains geographic coordinates for millions of entities: cities, landmarks, heritage sites, universities, and more. Geospatial queries let you find places near a point, within a region, or calculate distances between locations.

The Wikidata Query Service provides powerful geospatial features including:

Geospatial Topics

Geospatial Queries by Domain

Programming: Tech Hubs Worldwide

Headquarters of Programming Language Creators
Run ↗
#defaultView:Map
SELECT ?lang ?langLabel ?developer ?developerLabel
       ?hq ?hqLabel ?coord
WHERE {
  ?lang wdt:P31 wd:Q9143 ;
        wdt:P178 ?developer .
  ?developer wdt:P159 ?hq .
  ?hq wdt:P625 ?coord .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
LIMIT 100

Cultural Heritage: Museums Near You

Art Museums Within 50km of Paris
Run ↗
#defaultView:Map
SELECT ?museum ?museumLabel ?coord ?dist
WHERE {
  # Paris coordinates
  BIND("Point(2.3522 48.8566)"^^geo:wktLiteral AS ?parisLoc)

  SERVICE wikibase:around {
    ?museum wdt:P625 ?coord .
    bd:serviceParam wikibase:center ?parisLoc .
    bd:serviceParam wikibase:radius "50" .  # km
    bd:serviceParam wikibase:distance ?dist .
  }

  ?museum wdt:P31/wdt:P279* wd:Q207694 .  # art museum

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en,fr" .
  }
}
ORDER BY ?dist
LIMIT 50

Urban: City Infrastructure

Metro Stations in a City
Run ↗
#defaultView:Map
SELECT ?station ?stationLabel ?coord ?lineLabel
WHERE {
  ?station wdt:P31 wd:Q928830 ;  # metro station
           wdt:P131* wd:Q90 ;     # in Paris
           wdt:P625 ?coord .
  OPTIONAL { ?station wdt:P81 ?line . }  # metro line
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en,fr" .
  }
}

Geospatial Properties & Services

Key Properties

Property ID Description
coordinate location wdt:P625 Geographic coordinates (WKT point)
located in wdt:P131 Administrative territorial entity
country wdt:P17 Country where entity is located
headquarters location wdt:P159 Location of headquarters
location wdt:P276 Location of event or item

Wikidata Geo Services

Service Purpose
wikibase:around Find entities within a radius of a point
wikibase:box Find entities within a bounding box
geof:distance Calculate distance between two points

Visualizing on Maps

Add #defaultView:Map as the first line of your query to automatically display results on an interactive map in the Wikidata Query Service. The map will plot all entities that have coordinate values in the results.

Map View Magic Comment
#defaultView:Map
SELECT ?item ?itemLabel ?coord
WHERE {
  # Your query here - must include ?coord
  ?item wdt:P625 ?coord .
  ...
}

Continue Learning

← Temporal

Work with dates, timelines, and history.

Go Back
🌐

Multilingual →

Query across languages and scripts.

Continue