OpenStreetMap to GeoPackage with ogr2ogr
How GDAL's OSM driver turns OpenStreetMap data into a GeoPackage, with a tested command.
The GDAL worker behind this site does not accept OSM files. On your own computer ogr2ogr converts them in one command. This guide shows what the OSM driver produces, tested with a small hand-written .osm file.
Guide: run this conversion locally with GDAL
The GDAL worker behind this site does not accept .osm or .pbf files. Run the command below with GDAL on your computer.
What the command does
- GDAL's OSM driver always creates five layers: points, lines, multilinestrings, multipolygons and other_relations.
- Only nodes with tags become points; untagged nodes (e.g. corners of a way) are not output as points.
- Tags that have no own column in GDAL's default osmconf.ini go into the text field other_tags, e.g. "railway"=>"station".
- Closed ways such as buildings end up in multipolygons, with the way id in osm_way_id.
GDAL command to run locally
For .osm.pbf files the same OSM driver is used according to the GDAL documentation (not part of our test).
Tested with
| Test file | Result |
|---|---|
| Hand-written .osm: 1 tagged node (Köln Hbf, railway=station), 1 street (highway, maxspeed), 1 closed way with building=yes | points (1, other_tags "railway"=>"station"), lines (1, highway=residential, other_tags "maxspeed"=>"30"), multipolygons (1, building=yes, osm_way_id 11), multilinestrings (0), other_relations (0) |
Tested on 24 Sep 2026 with GDAL 3.10.3 (conda-forge build on Windows).
Limits
- Only tested with a small .osm XML file; large extracts and .pbf were not tested.
Frequently Asked Questions
Where are my tags?
Tags with their own column in GDAL's default osmconf.ini (e.g. name, highway, building) get a column; all others are in other_tags as text like "maxspeed"=>"30".