Wikipedia:Creating shape maps from OpenStreetMap data

This is a tutorial for creating interactive maps on Wikipedia for shapes using OpenStreetMap data, available on a compatible Open Database License. This is applicable for creating maps of neighborhoods, parks, historic districts, campuses, and most other present-day sites. For maps of lines (transit routes, roads, etc.), see Wikipedia:Creating route maps from OpenStreetMap data.

This tutorial requires basic knowledge of:

If you need help please use the talk page, User talk:Ɱ, or Module talk:Mapframe.

Part 1: Finding the shape data

edit

There are three methods you can use to find the 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 shape. As an example: {{maplink|frame=yes|type=shape|id=Q160236}} 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
 
After right-clicking the shape you want to map (for instance, Scioto Audubon Metro Park), click 'Query features' to bring up the lefthand toolbar. Select the feature name to bring up its relation.
  1. Go to OpenStreetMap and zoom into the general area where the shape is.
  2. Right-click (control-click on Macs) on the shape and select 'Query features'. This will also display shapes that may otherwise not be visible.
  3. Then search through the list for the shape you desire; selecting it will bring you the relation representing the shape, with the shape 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. Note: this can only be used for shapes that are relations, not ways.

  1. Go to the OSM Relation Analyzer.
  2. Type in the item name and click 'Search'.
  3. Click the relevant relation ID (generally several digits long), then click 'Browse' to see it on the OpenStreetMap website.

If you found the data on OSM, continue on to Part 3. If you did not find it, continue to Part 2 first to create the shape on OpenStreetMap.

Part 2: If you need to create the shape

edit

This optional step is only for shapes that are not already mapped on OpenStreetMap. Note that the entity you want to map must be an existing place in order to be accepted on OpenStreetMap, as OSM is not intended to map out historical, fictional, or unrecognized entities.

  1. Sign up or log-in to OpenStreetMap.
  2. If you are a new user, read through the website's walkthrough for how to edit.
  3. Find an existing reliable source for the shape (e.g. park or historic district boundaries as posted on a government website)
  4. Align the map to the area you want to edit.
  5. Click 'Edit' by the website banner.
  6. Now you should see the 'Add Feature' options at the top, with buttons for 'Point', 'Line', and 'Area'. Click 'Area'.
  7. You can now start to form a shape, clicking on each corner, adjusting the edges of the shape as needed.
  8. You can press 'Escape' on your keyboard to finish the shape. Before you save, use the toolbar to mark the shape for what it represents (a park, water body, building, etc.)
  9. You can now name the object, add a Wikidata ID, Wikipedia article associated with the shape, or anything else relevant to add. Hit the check mark in the same toolbar when complete.
  10. At the top right, click the 'Save' button. You will be prompted to write a description of your edits. Click 'Upload'.
  11. You have now added a shape to OpenStreetMap! It may take several minutes before it displays, but you can already find it outside of the editing screen (right-click, select 'Query features', and find your shape on the toolbar's list) and use it for Wikipedia.

Part 3: Embedding the shape into an article

edit

There are two ways to embed the shape into an article, both using the {{maplink}} template:

Method 1: Using Wikidata

edit

If the shape has a Wikidata item and the OpenStreetMap shape relation already has a wikidata tag set to that item's QID, you can embed a map of the shape 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|type=shape|id=Q160409|text=[[Central Park]]}}

Method 2: Using Wikimedia Commons

edit

Using map data on Wikimedia Commons:

  1. Paste the relation ID into this Overpass query, replacing '8343040'. The ID filter is actually one of many possible filters you could use here.
  2. Run the query, then click 'Export' in the toolbar and select the 'copy' part of 'download/copy as GeoJSON'
  3. In Wikimedia Commons, create a page in the Data: namespace with the .map extension, like Data:COTA10.map
  4. When you create the page, replace the 'Data' placeholder (including the two brackets) with the GeoJSON you copied.
  5. Uncomment the line "license": "ODbL-1.0", // ODC Open Database License v1.0 and save the page.
  6. 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.
  7. 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 shape changes in OpenStreetMap, repeat steps 1 through 3 to update the existing Wikimedia Commons map data page.

See also

edit

Notes

edit
  1. ^ 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.