I have some geospatial data in .osm format (edited, conflated in josm) that I'd like to export that into GeoJSON.

Are there any libraries or software that enable me to directly do this ?

I've read that it's possible to export osm data via the API to JSON but some of my data isn't able to uploaded to OSM and thus, not looking for an API-based solution.

(I've also found this tutorial where I'd have to first convert the data into a shp and then into geoJSON) but I'd prefer a more direct solution.

asked 06 Dec '12, 16:44

skorasaurus's gravatar image

accept rate: 12%

osmtogeojson is yet another OSM-to-GeoJSON converter. It's written as a javascript library, but can also be used as a command line tool: After installing it via npm install -g osmtogeojson you can use it like this:

osmtogeojson in.osm > out.geojson

But one can also use the library in javascript (browser or nodejs) projects. Take a look at the demo page.

The converter is quite feature-complete. It supports multipolygons, has sophisticated polygon detection and can cope with incomplete OSM data.

The code is already in use on geojson.io as well as overpass-turbo.eu (of which it is a spin-off, actually). The sources are found on github (MIT licensed).

permanent link
This answer is marked "community wiki".

answered 21 Oct '13, 10:54

tyr_asd's gravatar image

accept rate: 64%

I've found this javascript that converts OSM to geojson. Excellent.

The newest version of ogr2ogr (v. 1.10) also supports conversion from osm to geospatial formats including geojson.

permanent link

answered 05 Mar '13, 21:31

skorasaurus's gravatar image

accept rate: 12%

edited 22 Oct '13, 18:03

osm2geo is actually a javascript script, not python. ;)

Unfortunately, it only does a very basic data conversion (no multipolygons, tag agnostic polygons, etc.).

(21 Oct '13, 10:44) tyr_asd

JOSM is able to export to GeoJSON, but it depends on what you need. There's no support for relations (that I know of).

permanent link

answered 11 Dec '12, 14:37

Sanderd17's gravatar image

accept rate: 31%

One possible workaround that I've found is that I can open an .osm in qgis (using the OSM plugin, in the default qgis repository. Install by just searching for openstreetmap in the 'manage plugins'). and then saving it as a geojson.

(Still looking for a direct, command line option).

permanent link

answered 07 Dec '12, 15:20

skorasaurus's gravatar image

accept rate: 12%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 06 Dec '12, 16:44

question was seen: 13,401 times

last updated: 22 Oct '13, 18:03

powered by OSQA