Geospatial
Map Visualizations
Display query results on interactive maps using Wikidata Query Service's built-in visualization features. Create beautiful geographic presentations.
Default View Magic Comments
Wikidata Query Service supports special comments that change how results are displayed.
Add #defaultView:Map as the first line to render on a map.
| Comment | Description |
|---|---|
#defaultView:Map |
Display on interactive map |
#defaultView:Map{"markercluster": true} |
Cluster nearby markers |
#defaultView:Map{"hide": ["?coord"]} |
Hide coordinate column in popup |
Basic Map Visualization
Simple Map with Labels
#defaultView:Map
SELECT ?place ?placeLabel ?coord
WHERE {
?place wdt:P31 wd:Q515 ; # city
wdt:P17 wd:Q142 ; # France
wdt:P1082 ?pop ;
wdt:P625 ?coord .
FILTER(?pop > 100000)
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,fr" .
}
}
Maps with Custom Markers
Add images to map markers by including an ?image variable.
The image will appear in the popup when you click the marker.
Museums with Images
#defaultView:Map
SELECT ?museum ?museumLabel ?coord ?image
WHERE {
?museum wdt:P31/wdt:P279* wd:Q33506 ;
wdt:P17 wd:Q145 ; # UK
wdt:P625 ?coord .
OPTIONAL { ?museum wdt:P18 ?image . }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
LIMIT 100
Clustered Maps
World Heritage Sites with Clustering
#defaultView:Map{"markercluster": true}
SELECT ?site ?siteLabel ?coord ?country ?countryLabel
WHERE {
?site wdt:P1435 wd:Q9259 ; # UNESCO site
wdt:P625 ?coord ;
wdt:P17 ?country .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Colored Markers by Layer
Add a ?layer variable to color-code markers by category.
Each unique layer value gets a different color.
Infrastructure by Type
#defaultView:Map
SELECT ?item ?itemLabel ?coord ?typeLabel
(?typeLabel AS ?layer)
WHERE {
VALUES ?type {
wd:Q928830 # metro station
wd:Q55488 # railway station
wd:Q1248784 # airport
}
?item wdt:P31 ?type ;
wdt:P131* wd:Q90 ; # Paris
wdt:P625 ?coord .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,fr" .
}
}
Map with Rich Popups
Programming Language Origins with Details
#defaultView:Map{"hide": ["?coord"]}
SELECT ?lang ?langLabel ?coord
?place ?placeLabel
(YEAR(?inception) AS ?year)
?image
WHERE {
?lang wdt:P31 wd:Q9143 ;
wdt:P571 ?inception ;
wdt:P178 ?developer .
?developer wdt:P159 ?place .
?place wdt:P625 ?coord .
OPTIONAL { ?lang wdt:P154 ?image . }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
LIMIT 100
Other Visualization Types
Beyond maps, Wikidata Query Service offers other visualizations for geographic data.
| Comment | Use Case |
|---|---|
#defaultView:Globe |
3D globe view |
#defaultView:ImageGrid |
Grid of images |
#defaultView:BubbleChart |
Bubble chart (size by value) |
#defaultView:TreeMap |
Hierarchical treemap |