Wikipedia:Creating route maps from OpenStreetMap data
![]() | This help page is a how-to guide. It explains concepts or processes used by the Wikipedia community. It is not one of Wikipedia's policies or guidelines, and may reflect varying levels of consensus. |
This is a tutorial for creating interactive maps on Wikipedia for lines, using OpenStreetMap data, available on a compatible Open Database License. This is designed for transit routes, but is easily applicable for creating maps of roads, rivers, and other linear objects. For maps of shapes (neighborhoods, parks, historic districts, campuses, and most other present-day sites), see Wikipedia:Creating shape maps from OpenStreetMap data.
This tutorial requires basic knowledge of:
- finding Wikidata IDs
- using {{Maplink}} and its parameters (some helpful substitutes may be {{Infobox mapframe}} and {{Maplink-road}})
If you need help please use the talk page, User talk:Ɱ, or Module talk:Mapframe.
Part 1: Finding the route data
[edit]There are three methods you can use to find the route data you want for your map:
Method 1: Wikidata
[edit]The first thing to try is the easiest. There's a possibility your data is already linked and you're ready to map. Create a test map in your sandbox. You'll need to use {{Maplink}} together with the Wikidata ID of the route/line. As an example: {{maplink|frame=yes|type=line|id=Q928157}} If it displays, great. You can use the map and add parameters to make it display to your liking. If the map data does not populate, the below methods are straight-forward and reliable:
Method 2: Using the OpenStreetMap website
[edit]![](http://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Transport_OSM_map.jpg/400px-Transport_OSM_map.jpg)
- Go to OpenStreetMap and zoom into the general area where the route runs.
- Switch to the "Transport Map" layer using the
'Layers' sidebar on the right.
- Now you should see all the transit routes highlighted on the map, with numbers indicating the route numbers. Select a route by right-clicking (control-click on Macs) and selecting 'Query features'.
- Then search through the list for the route you desire; selecting it will bring you the relation representing the route, with the route displayed beside it on the map.
Method 3: Using the OSM Relation Analyzer
[edit]If you already know how the relation would be tagged, the OSM Relation Analyzer can be more convenient:
- Go to the OSM Relation Analyzer.
- Set Relation Type to route.
- Set Network to a route network identifier, such as COTA, or set Operator to an agency name, such as Central Ohio Transit Authority.
- Set Ref Tag to the route number, for example 10.
- Optionally set Route to bus if the same agency assigns the same route number to a bus line and another kind of route.
- Click 'Search'.
- Click the relevant relation ID (generally several digits long), then click 'Browse' to see it on the OpenStreetMap website.
Part 2: Embedding the route into an article
[edit]![Map](https://maps.wikimedia.org/img/osm-intl,10,a,a,180x200.png?lang=en&domain=en.wikipedia.org&title=Wikipedia%3ACreating_route_maps_from_OpenStreetMap_data&revid=1080853402&groups=_fa8d34dad336bef9b23a78faa782b11c6a072f86)
There are two ways to embed the route into an article, both using the {{maplink}} template:
Method 1: Using Wikidata
[edit]If the route has a Wikidata item and the OpenStreetMap route relation already has a wikidata
tag set to that item's QID, you can embed a map of the route directly onto a Wikipedia article as external data. Use the {{maplink}} template, setting the |id=
parameter to the QID, such as Q88466277. Normally, changes to the route in OpenStreetMap are reflected in the article within about two days.
Example: {{maplink|frame=yes|frame-width=180|id=Q126163|type=line|zoom=10|stroke-width=2|stroke-color=#00933C|text=[[New York City Subway]] {{NYCS|4}} train}}
Method 2: Using Wikimedia Commons
[edit]Using map data on Wikimedia Commons:
- Paste the relation ID into this Overpass query, replacing '8343040'. The ID filter is actually one of many possible filters you could use here.
- Run the query, then click 'Export' in the toolbar and select the 'copy' part of 'download/copy as GeoJSON'
- In Wikimedia Commons, create a page in the Data: namespace with the .map extension, like Data:COTA10.map
- When you create the page, replace the 'Data' placeholder (including the two brackets) with the GeoJSON you copied.
- Uncomment the line
"license": "ODbL-1.0", // ODC Open Database License v1.0
and save the page. - You may need to adjust the coordinates[nb 1] or zoom level in order for the map to display properly; here you can also add parameters for line width, color, etc.
- The route may also come with points indicating stops or stations; if you do not want to include these, you would have to remove the feature data, located at the end of your Json data.
- Then you can use the map data in Wikipedia articles, through {{maplink}} using the parameter
|from=COTA10.map
, or manually, like seen here.
Example: {{maplink|frame=yes|frame-width=180|frame-height=270|from=COTA8.map|type=line|stroke-width=2|stroke-color=#0e2c6c|text=[[Central Ohio Transit Authority|COTA]] route {{COTA link|8}}}}
If the route changes in OpenStreetMap, repeat steps 1 through 3 to update the existing Wikimedia Commons map data page.
See also
[edit]Notes
[edit]- ^ Here's an easy way to find the central coordinates for your new map: in Overpass Turbo, after running your query, click the
'zoom to data' button below the zoom buttons. Next, click on 'Export', then 'Map', and then 'current map view'. There, under the heading 'Center', is the center of your map. Simply copy and paste the coordinates into your Commons data page.