CLI GuideChannel: openstreetmapgeopackage

OpenStreetMap to GeoPackage Converter

Import OpenStreetMap spatial layers into structured databases.

This guide demonstrates how to extract OpenStreetMap records and organize them into SQL tables within a portable GeoPackage database. Organise points, polylines, and polygons into indexable database tables dynamically.

Indirect Mapping Execution Required

Because database connection attributes or local attributes parsing is required, direct web streams are disabled. Use the GDAL CLI script below for precise terminal conversions.

Specification Rules

  • Build offline mapping databases for desktop GIS applications
  • Organize complex road network layers into clean relational databases
  • Maintain historical regional map snapshots on isolated devices
  • OpenStreetMap raw files store topological structures, not simple spatial tables
  • Large scale extractions are subject to local storage constraints
  • Requires mapping configurations to structure key-value tags into database columns

GDAL Direct Equivalent Terminal Command

sh console shell
$ogr2ogr -f GPKG city_map.gpkg input.osm.pbf -oo CONFIG_FILE=osmconf.ini

Frequently Asked Queries

How are OSM tag pairs organized into database columns?

The GDAL extraction driver references settings in the 'osmconf.ini' file, mapping defined keys to direct columns while grouping unlisted tags into a single HSTORE database field.

Can I perform immediate spatial queries on the output?

Yes, GeoPackage natively utilizes SQLite, allowing you to run SQL statements with spatial search indexes.

How do I extract only building footprints?

Run a targeted SQL query selecting only features with active 'building' attributes.

Related Transformations Map