Getting Data
From OpenStreetMap
Data comes as .osm files, which are XML that describes OSM data.
Contents |
How Not to Do It
JOSM is useful if you want to edit OSM data, but not if you just want to download it. As of this writing, JOSM always draws the data that it downloads, and in fact does so inefficiently (understandable; try writing a geodata editor sometime). If all you want is to obtain data (for example, because you're uploading to a GPS device, or doing development, or doing something else with the data), don't use JOSM.
Getting a Specified Region (as a user)
Choose Your Region
The region is specified by a bounding box, which consists of a minimum and maximum latitude and longitude. Choose as small a region as will be useful to you, since larger regions will result in larger data files, longer download times, and heavier load on the server. The server may reject your region if it is larger than 1/4 degree in either dimension. When you're first starting out, choose a very small region so that you can figure things out quickly with small data sets.
Hopefully, as time goes by, it will get easier to visualize latitude and longitude using the OSM site itself. But, as of this writing, OSM doesn't do this very well. You can click "Permalink" to get an URL that contains some lat & long information, but it shows region size as a "zoom level", and you need to translate this into min and max coordinates. JOSM can translate a Permalink URL into a bounding box, but, as of this writing, this seems not to duplicate your online view very precisely - try it - and, as mentioned above, you don't want JOSM anyway for this task.
My favorite way to visualize latitude and longitude is through Google Earth. Turn on "Grid" in the View menu. You can set your preferences to display decimal degrees for compatibility with OSM.
See the bounding box discussion in the API docs for some hints about how bounding boxes work. In particular:
- Latitude and longitude are expressed in decimal degrees.
- North latitude is positive, south latitude is negative. West longitude is negative, east longitude is positive.
- In an URL, a bounding box is expressed as four comma-separated numbers, in this order: left, bottom, right, top (min long, min lat, max long, max lat).
Construct an URL for the HTTP API
Again from the bounding box discussion, this is the kind of URL you need to construct to ask the server for your .osm data file:
http://api.openstreetmap.org/api/0.5/map?bbox=11.54,48.14,11.543,48.145
The API is limmited to bounding boxes of about 0.5 degree by 0.5 degree. For larger areas you can use Osmxapi like so:
http://www.informationfreeway.org/api/0.5/*[bbox=-6,50,2,61]
Osmxapi allows filter specifications, in case you only want a specific subset of the data.
Download the Data
You can just type this URL into a browser if you want, but that may not work as well as you'd hope, especially if the data is large. If you know how to use them, command-line tools like wget and curl will do a better job.
If you've specified a region with a lot of data, you may have to wait a while before the HTTP response begins (the server is crunching your request). If your client times out, try setting options for greater patience, or choose a smaller region.
Here's an example command line for wget:
wget -O munchen.osm "http://api.openstreetmap.org/api/0.5/map?bbox=11.54,48.14,11.543,48.145"
Getting a Specified Region (as a developer)
See the protocol documentation.
Getting Everything
There is also the Planet file with the whole world. For some countries there is an excerpt of the Planet file restricted to those countries.

