Skip to main content
wording
Source Link

Standalone tools

You can try it with ogr2ogr and useusing the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note that ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might need to repeat the upper command with each layer. You will obtain 5 JSON layers finally.

An alternative can be osmtogeojson. It is written in JavaScript and has a commandline interface.

However, not sure if it works with large OSM files like yours.

PostgreSQL

Using PostgreSQL works for sure (like mentioned below).

You can import your OSM file using ogr2ogr, osm2pgsql or imposm. For the latter both you need to define which tags of OSM should actually be imported.

Once you have all your OSM data in the PostgreSQL database (probably in many tables) you can export them using ogr2ogr (like in this post):

ogr2ogr -f GeoJSON output.json PG:dbname="my_database" "my_table"

You can try it with ogr2ogr and use the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note that ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might need to repeat the upper command with each layer. You will obtain 5 JSON layers finally.

Standalone tools

You can try it with ogr2ogr using the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might need to repeat the upper command with each layer. You will obtain 5 JSON layers finally.

An alternative can be osmtogeojson. It is written in JavaScript and has a commandline interface.

However, not sure if it works with large OSM files like yours.

PostgreSQL

Using PostgreSQL works for sure (like mentioned below).

You can import your OSM file using ogr2ogr, osm2pgsql or imposm. For the latter both you need to define which tags of OSM should actually be imported.

Once you have all your OSM data in the PostgreSQL database (probably in many tables) you can export them using ogr2ogr (like in this post):

ogr2ogr -f GeoJSON output.json PG:dbname="my_database" "my_table"
wording
Source Link

You can try it with ogr2ogr and use the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note that ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might need to repeat the upper command with each layer. You will obtain 5 JSON layers finally.

You can try it with ogr2ogr and use the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note that ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might repeat the upper command with each layer. You will obtain 5 JSON layers finally.

You can try it with ogr2ogr and use the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note that ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might need to repeat the upper command with each layer. You will obtain 5 JSON layers finally.

Source Link

You can try it with ogr2ogr and use the OpenStreetMap driver.

 ogr2ogr -f GeoJSON output_points.json input.osm.pbf points
 ogr2ogr -f GeoJSON output_lines.json input.osm.pbf lines
 ...

Note that ogr2ogr reads OSM-files with 5 layers: points, lines, multilinestrings, multipolygons and other_relations. So you might repeat the upper command with each layer. You will obtain 5 JSON layers finally.