45

Is there a straightforward way to download data from OpenStreetMap (OSM)?

Using North America as an example, I realize Cloudmade (Cloudmade no longer provides downloads of OSM) and Geofabrik (http://download.geofabrik.de/osm/north-america/) both provide downloads, but the files are enormous (0.5gb - 4gb). I've also tried using the QGIS-OSM toolbar but I have not had much luck doing this, as similar to the OSM website the area you can select is very small. The amount of data I want to download is at the city level.

Finally, is there an easy of using OSM data? If I choose to download OpenStreetMap XML Data I can't open the osm.xml files using QGIS (even using the QGIS-OSM toolbar import function). I wonder if I'm missing a more obvious way of dealing with the data.


I just want to point out the very useful StackExchange clone for help with OSM related issues! http://help.openstreetmap.org/

8
  • 1
    but the files are enormous?? (0.5gb - 4gb) not in the GIS world - 5TB+ is getting normal
    – Mapperz
    Commented Mar 8, 2011 at 19:56
  • sorry - enormous for my puny machine. Not so much 0.5gb, but 4gb is unmanageable for me!
    – djq
    Commented Mar 9, 2011 at 9:45
  • Have explored this a little more, I find the data provided by geofabrik more comprehensive than cloudmade.
    – djq
    Commented Mar 24, 2011 at 14:31
  • 1
    @Nathanus I confess I just signed up..... It's true, but it really is focusing on every little detail about OSM many of which are programming related, and not specific to GIS. Though if subsites of subsites existed it would be perfect. The fonts over here are so much crisper!
    – djq
    Commented May 4, 2011 at 18:09
  • 1
    @djq the CloudMade downloads site is returning a 404 now - it may have been discontinued? Commented Sep 3, 2014 at 6:59

9 Answers 9

35

JOSM

Perhaps the easiest answer to both parts of your question, is to use JOSM. The Java OpenStreetMap Editor. It's easy to download data, and easy to "use" data.

For downloading, JOSM provides a simple interface to let you select a rectangular area to download, however it downloads this via the editing API. This will reject any request which is way too big, and if it's a little bit too big it will spend a long time thinking about it. Generally a whole city is way too big, but you might be able to get a good a chunk of data by requesting several rectangular areas.

For "using" the data JOSM lets you see the data and have a good poke around in all the tags. The search feature is quite powerful, allowing you to select elements with particular tags, but beyond that it really depends what kind of "use" you have in mind. You can configure the way JOSM displays the data to some extent, but for nice looking maps you'd probably want to look at rendering tools designed to work with OSM files. You can also look at conversion e.g. to shapefile, but bare in mind the data is ...different ...to what you might be used to, so this conversion is always a bit lossy.

As an aside... Although it's reasonably nice data viewer, the primary purpose of JOSM is to be an OpenStreetMap editor. Just click 'upload' to send changes back to OpenStreetMap (you'll need to create an OpenStreetMap account) If you didn't try OpenStreetMap editing yet, you really should. Anyone with even a passing interest in maps should give this a go. Add your local restaurant to the map or something like that. It's the only way to get a proper understanding of OpenStreetMap, and it's fun!

Bigger files

What if a city is too big to load into JOSM? There's some other options (as follows) but when you're dealing with this amount of data there's no escaping the fact that it's going to be a little bit difficult to "use". You're really out of the realm of fun little GUI tools and into big data GIS. The easiest entry to this (which is not all that easy) would probably be to load a large .osm file into PostGIS database using osm2pgsql, and then use GIS desktop tools to view it.

City extracts

This download.bbbike.org service offers ready-made downloads for some world cities.

Osmosis

If you need a different city or different bounding box, then you need to get one of the massive downloads you mentioned (either a country extract, or the whole planet) and then extract a piece out of it.

osmosis is the most widely used tool for this. It's a java command line tool letting you extract a bounding box on the unix command line with something like this:

bzcat downloaded.osm.bz2 | osmosis\
  --read-xml enableDateParsing=no file=-\
  --bounding-box top=49.5138 left=10.9351 bottom=49.3866 right=11.201 --write-xml file=-\
  | bzip2 > extracted.osm.bz2

This shows how you would typically avoid filling your disk with bloated XML data by uncompressing a .bz2 file, piping the output into osmosis and then piping the resulting XML into a bzipped file again.

So maybe this is not fitting with your definition of "easy", but osmosis is a worthwhile tool to get the hang of if you're interested in manipulating big .osm files. You just have to figure out the right command! (good topic for another question I guess)

3
  • I have used JOSM - it's very nice. However, I'm interested in large amounts of data, usually an entire city which I can't do within it.
    – djq
    Commented Aug 18, 2011 at 11:10
  • I've extended by answer to go into some of the options for working with larger files. Not as easy unfortunately, but hope that helps.
    – Harry Wood
    Commented Mar 2, 2012 at 13:30
  • Thanks @Harry. I ended up using osmosis on linux and it worked fine. I currently want to use this setup on Win 7 and I'm excited to see there is a .exe of bzcat. Last time I checked there wasn't. Unfortunately there does not seem to be an easy way of using osm2pgsql on Windows, otherwise that would be my ideal choice.
    – djq
    Commented Mar 2, 2012 at 15:56
25

Downloading OSM with QGIS on Demand

enter image description here

http://mapperz.blogspot.com/2009/11/openstreetmap-data-on-demand-with.html

6
  • 2
    +1 Wow that was prescient! You answered this question 16 months before it even appeared :-).
    – whuber
    Commented Mar 8, 2011 at 20:39
  • 1
    I have a Flux Capacitor en.wikipedia.org/wiki/DeLorean_time_machine#Flux_capacitor
    – Mapperz
    Commented Mar 9, 2011 at 15:29
  • Just a note on this - it does work on the current release of QGIS that I am using (1.7), but it only allows very small areas to be downloaded.
    – djq
    Commented May 3, 2011 at 20:56
  • quote from Mapperz blog "The data has been downloaded directly from the Open Street Map Servers [most up to date data]. **There are area limitions controlled by OpenStreetMap Servers, the plugin will warn you of this issue if required"
    – Mapperz
    Commented May 3, 2011 at 21:18
  • @celenius: the size limit is there because this OSM Web service is intended for mapping purposes (i.e. downloading small areas, editing them and uploading back). Using it just for read-only purposes is generally frowned upon because it burdens the already overstretched OSM infrastructure.
    – Igor Brejc
    Commented Aug 18, 2011 at 10:53
16

The simple answer is no there is no quick and easy way to do this. If you want city level data for the whole of North America it will be a huge file. If you want a smaller area then CloudMade do state by state files. You can see my notes on the process at http://ian01.geog.psu.edu/geoserver_docs/data/openstreetmap/osm.html but I didn't have much fun. I started to look at Osmosis (http://wiki.openstreetmap.org/wiki/Osmosis) but ran out of time before I got it to do much but it may be a solution to your problem.

As for using OSM data you can either go for their non standand/ neogeogrpahy approach and use mapnik etc or import the data into PostGIS and make it work in some proper GIS tools.

6

Echoing @iant's suggestion, if you are looking for just USA data, why not consider just download a state-by-state layer for your particular area of interest from Cloudmade? And if your area of interest is a can be just a couple of state's worth of data, the simplest way of using the data would be to download the shapefile extracts (State of Oregon example) which you can use in virtually any common GIS program.

1
4

Probably the easiest and cleanest way to download OSM data for arbitrary map area would be to use one of OSMXAPI servers. OSMXAPI API is intended to be used for read-only access to the geo. data (unlike the primary OSM API which is oriented towards editing). It also allows downloading of larger areas than the primary API.

One of the ways to access OSMXAPI is to use the Export tab at http://www.openstreetmap.org/ (choose "OpenStreetMap XML Data" radio button).

3
  • Do you have a recommended server? I tried a few and got timeout errors (I think). I've since been working with a copy of the entire globe on a local computer.
    – djq
    Commented Aug 18, 2011 at 12:27
  • I usually use this one: open.mapquestapi.com/xapi/api/0.6 .
    – Igor Brejc
    Commented Aug 18, 2011 at 13:46
  • 1
    OSMXAPI was always a bit weird, and these days no longer exists as a running service anywhere. Closest equivalent is the more powerful Overpass_API, but there's a few other websites which do it too extract.bbbike.org and export.hotosm.org
    – Harry Wood
    Commented May 15, 2018 at 16:43
3

The company WeoGeo now enable free downloads of OpenStreetMap data. You can sketch an outline of the area that you want data for and a file is generated.

1
  • Checked today, the domain is gone...
    – til_b
    Commented Mar 24, 2023 at 8:38
3

For metro extracts (200 popular metro cities): https://mapzen.com/data/metro-extracts/

For country/continent extracts: http://download.geofabrik.de/asia/india.html

Both of these are updated regularly as well.

1

https://extract.bbbike.org/ allows download required areas in various formats. it's best for use in gis.

https://export.hotosm.org/ also provides downloads services in few regions

0

You can download OSM features as GeoJSON without downloading enormous .osm.pbf files, needing osmosis, or JOSM. There are two free APIs for this.

Pulling from third-party OSM API

This API lets you download OSM features by tag (leisure=park) and optionally provide a bounding box (xmin,ymin,xmax,ymax). Here is an example:

curl --get 'https://osm.buntinglabs.com/v1/osm/extract' \
     --data "tags=sport=rugby" \
     --data "api_key=demo"

# optionally pass e.g. --data "bbox=-9.424,38.634,-8.820,38.80`

This is the easiest way to download data from OpenStreetMap. You can download ~10k geometries from all over the planet in ~2 min. There is no max download size. It does however require an API key (here).

Overpass Turbo

You can also use Overpass Turbo, which has a graphical interface. You can use both the wizard and the export as GeoJSON button. Here's an example query that also pulls for sport=rugby:

[out:json][timeout:25];
// gather results
(
  // query part for: “sport=rugby”
  node["sport"="rugby"]({{bbox}});
  way["sport"="rugby"]({{bbox}});
  relation["sport"="rugby"]({{bbox}});
);
// print results
out body;
>;
out skel qt;
1
  • Could you add the file format(s) the buntinglabs API provides?
    – til_b
    Commented Mar 24, 2023 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.