Jump to content

Wikipedia:WikiProject U.S. Roads/Maps task force/Tutorial

Route map:
From Wikipedia, the free encyclopedia
Map Tutorial
A subpage for a department of the U.S. Roads WikiProject
The U.S. Roads WikiProject
New user orientation
General
Project home (WP:USRD) talk
Portal (P:USRD) talk
Project category
Discord (WP:DISCORD) talk
Popular pages (WP:USRD/PP)  
Recognized content (WP:USRD/RC)  
Departments
Assessment
Assessment home (WP:USRD/A)
 → Statistics table  
 → Log  
 → Category  
 → Visual aids  
By-state assessment (WP:USRD/A/S) talk
 → Live table (WP:USRD/A/L) talk
 → WikiWork (WP:USRD/A/WW) talk
 → State audits (WP:USRD/A/SA) talk
A-Class review (WP:HWY/ACR) talk
Maps
Maps home (WP:USRD/MTF) talk
 → Requests (WP:USRD/MTF/R) talk
 → Tutorial (WP:USRD/MTF/T)  
Newsletter
Newsletter home (WP:USRD/N) talk
 → Newsroom (WP:USRD/NR) talk
 → Past issues (WP:USRD/N/I)  
 → Subscribe (WP:USRD/N/S)  
Resources
Resources (WP:USRD/RES) talk
AASHTO minutes (WP:USRD/AASHTO)
Lengths (WP:USRD/L) talk
Maps (WP:USRD/MDB) talk
Periodicals (WP:USRD/PER) talk
Shields
Shields home (WP:USRD/S) talk
 → Requests (WP:USRD/S/R) talk
 → Tutorial talk
 → Research  
 → Database  
Task forces
National task forces
State task forces
Portals
Editing guidelines
Article standards (WP:USRD/STDS)  
Naming conventions (WP:USSH) talk
Road junction lists (WP:RJL) talk
Notability (WP:USRD/NT)  
Rockland County Scenario (WP:USRD/RCS) talk
Michigan Plan (WP:USRD/MP) talk
Route Lists (WP:USRD/STDS/L) talk
Project resources
Participants (WP:USRD/PAR)  
Article alerts (WP:USRD/AA) arch.
Essays (WP:USRD/E) talk
Precedents (WP:USRD/P) talk
Things to do
To-do list
General stubs  
Project maintenance categories  
Articles needing attention  
Articles needing maps  
Articles needing shields  
Interstate RJL compliance talk
Systems and lists
Redirect lists
Templates
{{WikiProject U.S. Roads}} (doc) {{USRD}} talk
Article templates (WP:USRD/AT)
Barnstar list (WP:USRD/BS)
{{Infobox road}} talk
{{Infobox road small}} talk
{{Jctint}} talk
{{Jct}} talk
Stub templates (WP:USRD/STUB)
Userbox list (WP:USRD/UBX)
{{HWY Announcements}} talk
{{Welcome-roads}} talk
related changesv · d · e

Creating a KML file

[edit]

Using Google Earth

[edit]
This portion of the tutorial was contributed by User:Floydian.

The simplest method for most people to create a KML file is using Google Earth, which is free and works on most modern computers.

First time setup
Get Google Earth Ubuntu 11.X tutorial
  1. Start up the software.
  2. In the Tools menu, at the top, select Options... to bring up the Google Earth Options dialog. By default it should be on the 3D View tab. If not, set it to be.
    • In the Mac version, select the Google Earth menu and Preferences...
  3. Under Terrain Quality, set the Elevation Exaggeration to 0; press Ok.
    • This eliminates the surface elevations, making it easier to spot straight lines.
  4. On the left are three collapsible navigation panes: Search, Places and Layers.
  5. Start by unchecking all of boxes in the Layers pane except Borders and Labels and Places.
    • You may optionally wish to use the roads layer, but it can be a hindrance at times.
  6. In the Places pane, on the left, you will see the My Places tree, and Temporary Places. Right-click My Places and Add>Folder in which to save your routes.
Drawing
  1. In the Places pane, right-click the folder you are storing your routes in and select Add>Path to bring up the Google Earth - New Path dialog box.
  2. Name it after your highway
  3. In the Style, Color tab, set the color to pure red (second column, fourth row in the palette or r:255 g:0 b:0) and set the width to 5.0.
  4. Without closing the dialog box, start tracing your line. You may want to drag the dialog box over to the side; it can be annoying.
    • Once the dialog box has lost focus (i.e. you click to place your first point on the map), you can use your arrow keys to pan the map.
  5. Create your line, point-by-point.
Exporting
  1. Once you have finished tracing your line, press ok on the dialog box to close it. Your new path should be listed in the Places pane, within your folder.
  2. Right-click that entry (or the line itself on the map), and select Save Place As...
  3. Change the Save as type to Kml (it defaults to .kmz when you start the program).
  4. Save the file
  5. Locate the file on your computer and open it with a plain text editor.
  6. Select all>Copy
  7. Now create a new subpage of Template:Attached KML using the title of the article – Ontario Highway 401 becomes Template:Attached KML/Ontario Highway 401)
  8. Paste the content into this new page and save.
  9. Now add {{Attached KML}} to the article itself, in the External links section if it exists.
  10. Profit.

Observation

[edit]
This portion of the tutorial was contributed by User:Fredddie.

It is possible to add more than one .kml file to the KML subpage; that is, you can add a business route if you so desire. However, only Bing Maps will show both routes correctly. Google Maps will only show the last kml file on the page. If you add a business route, it must come before the mainline, otherwise Google Maps will only display the business route.

  • By copying the <Placemark></Placemark> and everything in between, you can merge multiple segments into a single KML file.
  • You can also export a folder in Google Earth as a KML, and it will contain all the lines within that folder when you saved it.

Editing an existing file

[edit]
This portion of the tutorial was contributed by User:SounderBruce.
  1. Copy the text in the Template:Attached KML subpage into a blank text file
  2. Save the file as a .kml (see the Exporting section above) and open it in Google Earth
  3. In the Places pane, right-click on your KML file select and "Properties" from the menu
  4. Use your mouse to hover over the desired points in the path that you would like to change. It should be highlighted in a color different from your path's (by default, green or blue)
  5. From here you have several options:
    • Left-click and drag to move the point
    • After left-clicking a point, click outside of the KML's path to create new points and a line that travels to the nearest point to your initial point
  6. Points can be deleted by hovering over
  7. Click the Save button in the dialog box to save. You can also click Cancel and undo changes made to KML since the last saved version
  8. Export the KML as shown in the Exporting section above, preferably to a new file
  9. Copy and paste the changed coordinates of your new KML file into the Template:Attached KML subpage. Make sure to leave an informative edit summary describing what areas were changed.

Using Google Maps

[edit]
This portion of the tutorial was contributed by User:Thewombatguru.

Creating a KML file using this method will only take you about 10 minutes on average and the only things you need are a Google-account and a text-editor.

  1. Go to Google Maps.
  2. Sign in to your account.
  3. Click on "My custom maps" and then click on "Create".
  4. Rename "Untitled map" in the top right corner to the name of the road.
  5. Click on the "Add directions" icon underneath the search bar.
  6. Enter the beginning and end of the road at "A" and "B", drag the markers to the exact places on the map if they are a bit off.
  7. Check if the given route follows the roads you want, if it doesn't, hold down the left mouse button on a part of the route and drag it to the desired road.
  8. Name your just created directions after the name of the road, followed by a brief description. (e.g. "Test route 54 - West to East" if the route is called "Test route 54")
    1. Repeat step 5 through 8 if you want to have more routes on the same map.
  9. Delete the empty "Untitled layer" by clicking on it, then selecting the little downwards arrow and clicking "Delete this layer". Confirm you want to delete it.
  10. Click on the folder button next to the "Add layer" button and click "Export to KML", then click "Download" and save it somewhere on your computer.
  11. Unzip the .kmz file you downloaded, inside should be a .kml file. (You might have to change the file extension to .zip first)
  12. Open the .kml file with a text editor (preferably Notepad++).
  13. Replace the text in between the third "<Name>" and "</Name>" parameters with the text in between the second "<Name>" and "</Name>" parameters, and rename that text to the name of the route. (e.g. "Test route 54")
  14. Scroll down through the coordinates of the first route until you see "</coordinates>".
    1. If you made another route, delete everything from "<placemark>" to the third "</name>".
    2. Add a "0" to the "<styleUrl>" paramater. (e.g. from "<styleUrl>#line-1267FF-1</styleUrl>" to "<styleUrl>#line-1267FF-10</styleUrl>")
    3. Replace the text in between the "<Name>" and "</Name>" parameters with the name of the road followed by a brief description. (e.g. "Test route 54 - East to West" if the route is called "Test route 54")
      1. If you made even more routes, repeat step 13, but for the third route add two "0"s, for the fourth three "0"s, etc.
  15. Scroll down through the coordinates of the last route until you see the "</coordinates>" parameter. Delete everything from "<placemark>" to the second "</placemark>"
  16. If you made more than 1 route, copy the last "<style>" section and paste it underneath it.
    1. Add "0"s to the style ids so they correspond with the ids given before. (e.g. from "<Style id='line-1267FF-1>" to "<Style id='line-1267FF-10>")
    2. Change the figure in between the "<width>" and "</width>" parameters to "5".
    3. Change the figures and letters in between the "<color>" and "</color>" for the first route to "FF0000FF", for the second route to "FF00FFFF", and for all remaining routes to "FFFF0000".
  17. Save the file and copy all the text.
  18. Go to Template:Attached KML/ followed by the exact name of the road article, paste the text on the new page, and safe it. (e.g. for road "Test route 54" go to Template:Attached KML/Test route 54)
  19. Add {{Attached KML|display=inline,title}} to the road article itself in the "References" or "External Links" sections. See link below.
  20. Go to the talk page of the road article and edit the page, add "needs-kml=no" to the {{WikiProject U.S. Roads}} template or change "needs-kml=yes" to "no".
  21. You've now created your KML file and added it to the corresponding article. Congratulations!
KML is not from Wikidata

Using qGIS and shapefiles

[edit]
This portion of the tutorial was contributed by User:Scott5114.

Having created a map as shown above, creating a KML file to attach to the article is simple. You can think of a KML file as basically a stripped-down version of a shapefile—it contains a set of geographic coordinates that express your route's location. However, while a shapefile encodes the coordinates as binary data, KML is expressed as textual XML data, which is easier to parse and edit. KML files are supported by many mapping applications, such as Google Earth, and can be reused by many people outside the project for a variety of purposes. Online mapping apps like Google Maps and Bing can also read and display KML files, which means that readers can choose to see the route highlighted on a map with towns and cities labeled that they can zoom in on and pan. The utility of generating a KML file is a no-brainer.

  1. You will need to have finished creating a map in QGIS in the manner described above. This walkthrough begins after approximately Step 22 of the above tutorial.
  2. Right-click the layer containing the "highlighted road" (the layer that contains just the road of interest, colored red). Select "Save as...".
  3. A dialog called "Save vector layer as..." should appear. Change the "Format" dropdown to "Keyhole Markup Language [KML]".
  4. Move down to the line labeled "CRS" and click "Browse".
  5. Expand the "Geographic Coordinate Systems" entry on the tree view. Find "WGS 84" and select it. Click "OK". (In the future, you will be able to select WGS 84 from the "Recently used coordinate systems" list.)
  6. Select a location to save the KML file to.
  7. Finally, click OK on the "Save vector layer as..." dialog. QGIS should notify you that the export was completed successfully.
  8. Open the KML you just generated in a text editor such as Notepad, emacs, etc.
  9. Copy all text in the KML file to the clipboard.
  10. Now you'll create a subpage of Template:Attached KML corresponding with the title of the article (for example, for the article Oklahoma State Highway 84, the KML page will be Template:Attached KML/Oklahoma State Highway 84. (Create this by going to the search box and typing in << Template:Attached KML/[name of page you have map for] >>. Wikipedia will tell you that page does not exist and allow you to create it. In this example, you'd type <<Template:Attached KML/Oklahoma State Highway 84 >> into the search box to create the subpage for it.)
  11. Paste the KML text into this page and save. Do not attempt to format it; doing so will break the XML. Any wikicode intermingled in the KML page will cause parsing problems. You may wish to note in the edit summary that the KML was generated with the same data as the article's map.
  12. Go to the article and place the text {{Attached KML}} in the article right below the heading for External Links. The template should be placed in the External Links section because it contains links to external websites. This Attached KML text with the curly brackets tells Wikipedia to look for the template with the same name as as page you are looking at and display that KML in the format set up for Wikipedia to display it. (Smart, hugh.)
  13. You're done! Users can now use the KML data.

Alternative using qGIS and shapefiles

[edit]
This portion of the tutorial was contributed by User:Allen4names.
You will need Quantum GIS and the shapefiles. I am using version 1.8.0 of qGIS for this tutorial.
  1. Open the .shp file(s) that have the data you want in qGIS.
    • For the example below I am using s53nhpn.shp (archive filename s53nhpn.zip) from the web site linked above.
  2. Go to the attribute table (right click on each layer) and select the records you want to use.
    • In this example I clicked on "SIGN1" at the top of the attribute table window and scrolled down to U12. I selected records 4023-4079 and repeated with "SIGN2" and "SIGN3" making sure not to unselect any.
  3. In the main window choose right click on each layer and choose "Save selection as...". Choose a file name and save.
    • Make sure that the format is "Keyhole Markup Language [KML]".
  4. Edit the file in a plain text editor to replace each instance of "<LineStyle><color>ff0000ff</color></LineStyle>" with "<LineStyle><color>ff0000ff</color><width>5</width></LineStyle>" and save.
  5. Check the file using Google Earth or paste the resulting code into a KML sandbox to test it using Google Maps or Bing Maps.
  6. If there is nothing wrong you can create a subpage of {{Attached KML}} using the code you created and add the template to the article.
    • It should be noted that I did find errors. There where two missing sections. One along I-5 and the other along I-82.

Using ShareMap.org social web mapping service

[edit]
Sharemap org screenshot
This portion of the tutorial was contributed by User:Jkan997.
  1. Go to ShareMap.org and create map (registration not required, but recommended)
  2. Draw your map, import data from Natural Earth and OpenStreetMap (with wizard or pure XAPI queries)
  3. Save map
  4. Go to tools tab in view mode and select KML export
  5. Save exported KML file
More informations
here
Recorded screencasts
here on YouTube

Creating an SVG file

[edit]

This is a tutorial for creating road maps for WP:USRD with QGIS and Inkscape. This tutorial was originally written by Xenon54. Contact him with any questions or inaccuracies.

  1. Install QGIS. For best results, use 2.18 Las Palmas which is the version this tutorial was written for. Newer versions will work too, just beware that some menus or options may be a little different compared to what the tutorial says. The latest version is currently {{LSR|
article = QGIS 
| latest release version = 3.40.1[1]Edit this on Wikidata
| latest release date = 22 November 2024; 10 days ago (22 November 2024). These links may not be up-to-date and are merely provided as a convenience; the official download page is here.
  1. Install Inkscape from inkscape.org. You'll be using it later.
  2. Now that you've downloaded QGIS, you need to feed it Geographic Information System data, herein referred to as just "data". It is freely available from many government and private sources. Here are some good places to start:
  3. Once you're done downloading data, fire up QGIS. You should get a blank screen.
  4. Go to Layers -> Add a Vector Layer, or press V.
  5. Browse to wherever you saved your data. You should see a .shp file. Double click it to import it. NHS data (state-level) will have a name of the form SXXNHPN, where XX is the state's FIPS state code -- for example, S39NHPN for Ohio. Census/ESRI data, which is county-level, will be named tgrXXXXXabc, where XXXXX is the FIPS state code followed by the FIPS county code and abc is a code indicating which type of data the file represents -- for example, tgr39103wat holds data for water bodies in Medina County, Ohio.
  6. We will be focusing on road data first. Now you should see a mass of lines, roughly forming the state's shape. It is time to give those lines some color. In the "Legend" on the left hand side, right-click the layer name and hit Properties. Note: this method will only work for NHS data. Census/ESRI street data does not contain sign designation data, only street names. You will have to leave this data all one color.
  7. Click Style on the Properties screen and find the drop-down menu that says "Single Symbol". Click the menu and select "Categorized". In previous versions, this was called "Symbology".
  8. In the "Column" drop-down, select "SIGNT1", then click the Classify button.
  9. A list of letters should appear. The amount is different for each state, but three are always present: "I" for Interstates, "U" for US Routes, and "S" for state highways. Each type should be assigned a color automatically.
  10. Click each class you want to color. Click the "Outline Color" box to the right and assign a color to the class based on the standards at WP:USRD/MTF. Here you can also change the width and style of the lines in that class. If you don't want a class to appear, select it and hit "Delete Classes". When you are done, click OK. You can also assign a label to the class by typing a name in the Label box.
  11. If you downloaded non-road data, such as water or county lines, go into its Properties now. Leave the "Legend Type" at "Single Symbol", and assign the proper color. If you're doing county lines, make the line width rather thick (~.8) so it will show up correctly in step 29.
  12. You probably have noticed that the road whose article is getting the map (herein: the "highlighted road") is orange or blue or some other color. You need to copy that road from the NHS layer to a new layer you will create to turn it red.
  13. There are two ways to select the road:
    Lasso method:
    1. This is only ideal for short roads. On the main toolbar, look for an icon that looks like an arrow with a small "i" next to it. It's next to the pan tool.
    2. Click the arrows next to this icon, and select the icon that looks like an arrow with a box on top of a yellow shape.
    3. Zoom in (click the arrows next to the pan tool to find the zoom tool) to where you can see your road clearly. Hold control and select the road so the region you want to highlight red is colored yellow. You can switch between pan, zoom, and select, just don't let go of control.
    4. Once you're done selecting, let go of control. Find the blue pen (edit layer) icon, then click the arrows a few icons to the right. Click the "copy selected" icon.
    Attribute table method
    1. Ideal for longer roads, but tough for roads such as the Ohio Turnpike that carry two different non-concurrent designations. Begin by right-clicking the NHS layer and selecting Open Attribute Table.
    2. A bunch of numbers, looking like a nightmare Excel file, appear. However, some of the numbers are very helpful. Scroll over to the SIGN1 column. This is the designation of the road and is a combination of the next two columns, SIGNT1 (type, which you may remember we used in coloring) and SIGNN1 (number). Concurrencies are indicated by additional entries in SIGN2 and SIGN3. To the right of SIGNN3 is LNAME, the name of the road segment being described by that row, followed by MILES and KM, which should be self-explanatory.
    3. Now, notice the search box at the bottom. Type the designation of the road you want to highlight (e.g. S11 for a State Route 11), select SIGN1 in first drop-down box, "show only matching" (or "select and bring to top", or "select", whichever you prefer) in the next drop-down box, then finally click Search.
    4. The matching records (hopefully corresponding to the road you want to highlight) will be selected or move to the top, depending on which option you picked. Select them and hit the "Copy selected rows to Clipboard" icon.
  14. Whichever method you picked, the road you want to highlight should now be yellow. Press N to create a new layer. Under "Type", select "Line". QGIS demands that you define an attribute here. An attribute is a column in the attribute table, such as "SIGN1". It doesn't matter what you call it or what type it is, just define one and click OK.
  15. QGIS asks you to pick a location to save the .shp file. Pick one and save it. The filename will be the name of your layer.
  16. Select the layer in the Legend on the left-hand side. Click the blue pen icon to enter into edit mode. Click the arrows to the right of the blue pen icon but to the left of the hand icon. Click the Paste icon in the box that appears.
  17. Click the blue pen icon to exit edit mode. Save the layer. If you get an "unable to commit changes" error, click don't save. It seems to save anyway.
  18. Finally, right-click the layer you just created. Click Properties, then the Symbology tab. Leave the Legend Type at "Single Symbol". Now, click on the Outline color box and make the highlighted road red. Be sure to change the width to make it stand out.
  19. At this point, the highlighted road (remember, the road the map is showing the path of) should be red.
  20. Now save: File -> Save Project. This will save the current layers and view as a .qgs file.
  21. Export the map as an file that can be used in Inkscape. To export it as a PNG, go to File -> Save as Image. Pick a place to save the image (preferably one where you'll remember where you saved it) and save as a PNG file. To export it as an SVG, see this page for the remainder of the tutorial.
  22. You're done with QGIS. Open Inkscape.
  23. Open the PNG file you just saved.
  24. Go to Path -> Trace Bitmap. A dialogue box will appear.
  25. Under "Multiple scans", select "Colors". Untick the "Smooth" box. Untick the "Stack scans" box.
  26. Click on the image to select it, then click Update to preview the trace.
  27. If you're satisfied with the preview, click OK and wait for potrace to work its magic.
  28. Once potrace is finished, move the traced image out of the way and delete the PNG. Put the traced image back when you're done. After you do this, right-click on the image and hit Ungroup. Now each color is a separate path. Interstates are all one path, state and US routes are all one path, but most importantly the highlighted road is its own path. This will make it easier to update the map for alignment changes, extensions, or truncations.
  29. You can add shields if you want. Use the SVG shields found on Commons. Be sure to save the SVGs, then go to File -> Import to add them to the map. If you don't, the thumbnail won't display come upload time.
  30. If you added shields, make sure to convert the shield text to path if necessary. Then, save as an SVG.
  31. You're done with Inkscape. Go to Commons.
  32. Upload your image. Remember to tag with {{Created with Inkscape}} or {{Inkscape-hand}}.
  33. Add your image to the article. Most, if not all, use {{Infobox road}}, which has a map parameter. Add in the form map=map_name where map_name is just the file name of the map (e.g. OHSR 8 map.svg, not File:OHSR 8 map.svg). Text can be displayed with the map_notes parameter.

Congratulations! You are finished!

  1. ^ "Release 3.40.1". 22 November 2024. Retrieved 26 November 2024.