Help Wikitravel grow by contributing to an article! Learn how.

Difference between revisions of "Wikitravel:How to create a map"

From Wikitravel
Jump to: navigation, search
(Configure an Image tag for the map in Wikitravel: start documenation for Image tag)
(Examples: nowiki blows out the page. Click edit to see the source.)
Line 81: Line 81:
 
==== Examples ====
 
==== Examples ====
  
<nowiki>
+
* From [[Paris/8th_arrondissement]]
  [[Image:Paris_8th_arrondissement_map_with_listings.png|thumb|350px|border=8ème arrondissement|is_in=Paris|relid=20872|expand_for_listings=no|listings_placement=manual|box1_x=10|box1_y=200|box1_h=90|box2_x=10|box2_y=10|box2_h=100|box3_x=164|box3_y=4|box3_h=0|box4_x=84|box4_y=249.2|box4_h=40|box_width=60|map of the 8th Arrondissement]]
+
 
</nowiki>
+
[[Image:Paris_8th_arrondissement_map_with_listings.png|thumb|350px|border=8ème arrondissement|is_in=Paris|relid=20872|expand_for_listings=no|listings_placement=manual|box1_x=10|box1_y=200|box1_h=90|box2_x=10|box2_y=10|box2_h=100|box3_x=164|box3_y=4|box3_h=0|box4_x=84|box4_y=249.2|box4_h=40|box_width=60|map of the 8th Arrondissement]]
  
 
===Generate map===
 
===Generate map===

Revision as of 12:26, 27 September 2009

This page gives detailed instructions for creating Wikitravel maps using OpenStreetMap data.

Contents

Instant maps

This easy three-step process can be used to create simple city street maps.

  1. Surf to openstreetmap.org. Navigate to your destination of choice.
  2. Click on the Export tab. Make sure "Mapnik Image" is selected and that the "Image Size" is sensible (between 2000x2000 and 3000x3000 is good). Click the Export button to download.
  3. Rename "map.png" as something more sensible and upload it to Wikitravel Shared. You're done!

Expert maps

This process can be used to create full-fledged Wikitravel maps with automatically placed and indexed icons for sights, restaurants, hotels, etc. It may seem a little unwieldy or intimidating the first time around, but almost all the work is really done for you, and it's infinitely faster than trying to draw your own map. So give it a shot!

Prerequisites: Access to a machine running modern flavors of Unix, preferably Linux and most preferably Ubuntu. Also, the Wikitravel destination that you want to map must already be using the new listings tag format.

Note that in the fairly near future these scripts should be running as a Mapmaker bot which you will be able to interact with using a Wikitravel:Category.

Process Overview

The map creation process now follows these steps:

  1. Download and install the Osmatravel scripts (formerly known as wtp-maps)
  2. Find your destination in Open Street Map
  3. Choose to either collect the map coordinates or create a boundary relation to define the region to be mapped
  4. Add an appropriate image tag to your article to configure the map create
  5. Run the scripts to generate an SVG image
  6. "Edit OSM" as necessary to improve your map
  7. Regenerate the SVG Image
  8. Examine and adjust the SVG as necessary
  9. Upload the SVG to Wikitravel shared
  10. Run the scripts to generate a PNG image
  11. Upload the PNG to Wikitravel shared

Download and install the scripts

  • Install xmlstarlet [1] as per the instruction on their website (sudo apt-get install xmlstarlet will install it on Ubuntu)
  • Download the current Gitorious tarball of the Osmatravel (formerly wtp-maps) scripts.
  • Unpack the tarball somewhere convenient, in your home directory for instance, or perhaps in $HOME/src.
 tar -xvzf osmatravel-osmatravel-master.tar.gz
  • This will create a new directory "osmatravel-osmatravel/" containing the scripts. Enter the directory.
 cd osmatravel-osmatravel
  • The first time you run the scripts you'll have to specify an article. If it's the first time you've generated a map for a given article it's best to do it in steps. For instance if you simply want to generate a config file for a particular article you can do this:
 make Config.mk ARTICLE=Paris/1st_arrondissement

Please note that spaces in the article name should be replaced by underscores (_).

  • You can reconfigure the scripts to use a different destination any time you like by doing something like this:
 make clean; make Config.mk ARTICLE=Paris/2nd_arrondissement


Find the destination in OSM

Choose a method for defining the bounding box

When you are configuring an article for map generation for the first time you have a choice to make about how you configure the map's bounding box.

  • You can draw a relation boundary around the are which you mean to map. The Osmatravel scripts will calculate a rectangular bounding box which contains this relation, regardless of its shape, plus some padding.
  • You can copy the lat-long coordinates of the corners of a rectangular area as viewed in OSM.

Each method has advantages: if you draw a relation it will be rendered in the map as a slightly lighter grey, giving the destination part of your map a little more visual relief. If you configure exact lat-long coordinates the scripts will run a bit faster. If you want both advantages you can use both methods.

Configure an Image tag for the map in Wikitravel

The Osmarender scripts now take their configuration information for a given destination from the Wikitravel article itself. This means that all configuration data for any particular map project is publicly available under a version of the CC by-sa license.

Configuration is done by adding some extra attributes to a MediaWiki Image tag for an appropriately named image. A couple of these are required by the scripts in order to render a map, but some of them are optional:

Required Attributes

Optional Attributes

Examples

map of the 8th Arrondissement

Generate map

  • Run the command make. This will automatically do the following:
  1. Download the OSM data within the border defined earlier into data.osm
  2. Download the Wikitravel article
  3. Extract all its listing names into listings.txt
  4. Match the listings against the OSM data
  5. Create a vector map called map.svg, including icons for all listings it could match
  6. Create a vector listings box called listings.svg
  • Check the file unmatched.txt, which contains all Wikitravel listings not found in the OSM data. If something did not match properly...
    • If you fixed the mistake in Wikitravel and saved your change, then run make wt-clean and run make again.
    • If you fixed the mistake in OSM, then re-export the data and run make again.

Edit in OSM

OSM Potlatch editor (satellite layer off)
  • Browse to the OpenStreetMap site and browse to your destination.
  • Click the [Edit] tab, which loads the Potlatch flash editor in your browser. [Play] around, read the docs and watch the video at the Potlatch page until you feel comfortable; then [Start] mapping.
  • Odds are other kind OSMers have already added the streets and basic city features, so your job now is to add and check the Wikitravel listings.
  • To add a new listing, double-click on a point on the map to create a new node. Choose the appropriate type (below), then click the [+] icon (lower left corner) and add new tags to it. The important tag is name, which must match the Wikitravel listing's name exactly. However, if Wikitravel is using the English name but OSM is not, you can add a name:en tag to the OSM node.

The following is a quick reference for mapping Wikitravel listings to OSM map features. The complete list is available here.

Wikitravel listing Type OSM tag OSM tag value
See Museum tourism museum
See Church, mosque, etc amenity place_of_worship
Eat Restaurant amenity restaurant
Drink Bar, pub amenity pub
Drink Nightclub amenity nightclub
Sleep Hotel tourism hotel
Sleep Hostel tourism hostel
Sleep Campground tourism camp_site
Bus station amenity bus_station
Train station railway station

Note that these tags are used by OSM only and are, at the moment and in general, not needed for Wikitravel map generation.

Defining the map's edges as a relation in Potlatch
  • To define the edges of your map, draw a way around the edges of the area, connecting back to the starting point.
    • Depending on your requirements, this can be a simple square box or a complicated district polygon.
    • Do not define it as a road or anything, just leave it as an unnamed way.
  • Click on the Relation Editor button (the "chain link" icon on the left side) in Potlatch.
    • Select "Create new relation".
    • Enter "type": "border". Click [+] to add a new tag, enter "name" and the Destination you entered earlier in Config.mk. Click [+] once more, enter "Is_In" and the Region from Config.mk. (See screenshot for an example.)

Clean up map

A "raw" OSM export
  • Load up map.svg in your favorite SVG editor, eg. Inkscape.
  • Find your city center. (OSM exports often contain lengthy roads and rivers sticking way out of the selected region, so you may need to zoom around.)
  • Draw a horizontal rectangle with Fill: None.
  • Select the rectangle with the pointer tool and set W(width) to 300.8 and H (height) to 173.0.
    • If you want a vertical rectangle, swap around the height and width.
    • If you have a large area, you can use multiple rectangles to cover it.
  • Resize the rectangle to your liking while pressing down CTRL; this keeps the proportions constant.
  • OSM exports may have overlapping city names, icons under streets and other slight messiness. Clean up the area within the rectangle to your liking.

Current versions of Inkscape allow you to edit OSM-generated maps, but hopelessly corrupt the output if you try to save them. The workaround below thus exports the SVG into a PNG bitmap and then continues work on that.


  • When finished, select the rectangle and choose File > Export Bitmap... from the menu. Choose "Selection" and enter 3008x1730 px as the size. Save it as "Destination-raw.png".
  • Close map.svg.

Check readability

If this is the first time you're exporting this city, this is a good moment to verify that the map is readable when printed. Load the map in GIMP (or another bitmap editor) and set Image > Print size... to be 6.875in wide and 3.95in high, then print it out on your printer (in grayscale mode). If you can read the street names without squinting, it's fine.

Finalize and export map

The finished map
  • Open a new Inkscape document and from File > Document Properties set it to be exactly 6.875in wide and 3.95in high.
  • Use File > Import... to import "Destination-raw.png"
  • Object > Align and Distribute it to align to the top edge and right edge of the page, then resize it (while pressing CTRL) until it precisely covers the page.
  • Use File > Import... to import listings.svg. Resize it, clean it up and place it on the map.
  • Do any last-minute tweaks.
  • Choose File > Export Bitmap... from the menu and export to 3008x1730px as "Destination.png".
  • Load the exported bitmap in GIMP (or another bitmap editor) and select Image→Mode→Indexed Color dialog. Select indexed mode, 64 colors, dithering off, and run the conversion -- this cuts down file size nicely.

Congratulations -- your map is done!

Help?

Need help? Something not working the way you think it should? Ask on the Talk page, or drop the maintainers of wtp-maps, User:Mark and User:Jpatokal, a line. Jpatokal 11:01, 9 June 2008 (EDT)

SVG imports for users without Linux access

If you lack access to a computer with a Linux operating system, you will have to go through several more manual steps to generate a map from OSM data.

Import

First, go to OpenStreetMap [2], zoom in on the area you wish to map, and then click the export tab. In this window, select "Mapnik Image" with an SVG format.

Choosing the appropriate scale depends to a degree on the size of the area being mapped, but in general you can get away with a low resolution export (which will decrease the file size of the exported SVG)—1:20,000 is not a bad resolution to start with. If the file size of the SVG export is too large, your computer may grind to a halt when modifying it in Inkscape [3].

The first and simplest thing you can do to reduce that filesize and make the SVG more manageable is to delete the light gray background object, which for some reason tends to include thousands of extraneous nodes. Be sure to vacuum definitions (File → Vacuum defs) after making such a significant deletion, in order to further reduce the file size.

Convert

Layers — separating content into layers will make your SVG more versatile and easier to manage (turning off complex layers will help speed up Inkscape). Create a layer for the OSM import, then add empty layers above it for streets, street names, etc.

First text. Unfortunately imported OSM SVGs do not contain text—all letters are in fact paths, which makes things more complicated. To begin, use the find operation (Ctrl+F) and enter "use" in the ID box; this should select all the black text in the SVG. Delete all selected "text." Then use the find operation again, and enter "stroke-miterlimit: 10" in the style box. Change the fill color of the selected objects to black, and remove the stroke color; all text will now appear in a more manageable form. Group the selected paths (text), move them to a text layer, then turn off that layer. (The text will likely need to be resized, and this can be done using the transform function → scale (Shift+Ctrl+M).)

This is where things get tricky. You must select all objects of one type (e.g., red-colored streets), combine them into one path (Ctrl+K), and then change the color to match the usual Wikitravel scheme. To select all paths/objects of one category, use the find operation. Red-colored streets are easy to select, for example, simply enter "stroke:#eb9799" to the style box in the find operation to select all red-colored streets. Combine the streets into one path, then move them to a dedicated streets layer, then turn that layer off. Repeat for all types of streets. To find unique attributes for the various street types, select one path, then open the XML editor (Shift+Ctrl+X), examine the style attribute, and find a unique value to enter into the find box. To match Wikitravel color standards, change the stroke colors to white (although freeways/highways can be colored red to distinguish them from city streets).

You will notice that most paths in the SVG have "shadow" paths behind them. Delete these paths. Also, selecting the street paths you have combined, then simplifying them (Ctrl-L) can reduce the file size and complexity of the SVG a good deal, usually without sacrificing much accuracy. At low resolutions, OSM SVGs display the street paths rather wide; select the combined street paths and change the stroke style width by an appropriate percent.

The colors of other objects, such as parks, buildings, and water areas, should also be changed to conform to Wikitravel standards. This can be done in the same manner, using the find function to select all objects of a specific type, and then using the fill function to change the color (or pattern). You can obtain standard colors and patterns here.

(Incidentally, if patterned objects display with the pattern appearing overly large, duplicate the patterned object(s), shrink the duplicated object(s) until the pattern displays at the desired size, then move the smaller object(s) to the bottom of the layer, combine it with the original object(s), then break them back apart, and delete the smaller duplicate object(s).)

Finish

The final tasks are much more simple, but are time intensive. What is left is to add travel icons, a key, title, compass, scale, etc. These tasks are described at Wikitravel:How to draw a map.

Variants

Actions

Destination Docents

In other languages