Using OpenStreetMap Overview Part 1: Obtaining mapping Data
OpenStreetMap is a community mapping project that allows you to upload then later use mapping data in a number of ways. One of their main benefits is providing maps free of the legal / technical limitations present on other services. Google Maps free edition for example can only be used when you provide a service which is “freely accessible to end users“.
The main issue with using OpenStreetMap however is map coverage, since they rely on user submitted data, maps may not be available for your area, however since starting in 2004 they now have good coverage in a number of areas, especially popular tows, and cities.
The map image data is supplied in the form of .osm files (containing XML describing the map features). There are two main types of file, the large “Planet” file containing all the mapping data OpenStreetMap currently has available for the entire planet (supplied directly by OpenStreetMap), and smaller “Extracts” files provided by contributors each containing only certain areas (i.e. Countries, or parts of countries). Additionally custom .osm files can be generated by using the Java OpenStreetMap Editor tool (“File” > “Download from OSM” then “File” > “Save as” options) however the total size is limited,
Converting .osm files to .png files
To convert the XML .osm files into .png image files that can be displayed by the web browser a rendering tool is required. There are two main tools available: Kosmos which runs on Windows and Mapnik that runs on a number of platforms, they are both very different in terms of what they can do and how easy they are to use.
Kosmos is fairly straight forward to install / use and has both a GUI and command line version available. It comes with a sample .osm file containing the Isle of White. To render the sample it is just of case of using the command line: Kosmos.Console.exe tilegen “..\Samples\Isle of Wight\Isle of Wight.kpr”. To render your own osm files edit the sample .kpr file removing configuration lines that are not required, and changing the location to the .osm file. [Download Example]
Kosmos may occasionally crash while starting up, this is generally due to someone editing the “Kosmos General Purpose Rules” page on the Wiki and failing to correctly test it (Kosmos downloads a copy of this file each time it runs). To stop this from happening, download your own copy of the raw rules file upload it to your web server, and change the “WikiPage” variable in the .kpr file. Kosmost however has a drawback in that it processes .osm files by first reading them into memory, therefore it is limited in the total size of .osm file it can process. For anything but small areas, another tool such as Mapnik is required.
Using Mapnik requires a non trivial setup procedure, for documentation on setting up and using Mapnik see the Mapnik OpenStreetMap Wiki page. As of yet I have not had any success setting this up on two different virtual machines running different OSs for which the Wiki provides setup instructions. My next attempt will involve the Fedors packages / instructions from Passback Mapping.
Also see Part 2: Making use of map data.