Skip to content

Instantly share code, notes, and snippets.

@do-me
Created November 10, 2025 09:44
Show Gist options
  • Select an option

  • Save do-me/77808843d38242f2b920b9ae77b652bd to your computer and use it in GitHub Desktop.

Select an option

Save do-me/77808843d38242f2b920b9ae77b652bd to your computer and use it in GitHub Desktop.
OSM: From .osm.pbf to parquet file with all streets for a region
osmium extract -b 12.2,36.5,15.8,38.8 italy.osm.pbf -o sicily.osm.pbf --overwrite;
osmium tags-filter sicily.osm.pbf w/highway -o sicily_streets.osm.pbf --overwrite;
ogr2ogr -f Parquet -oo PRELUDE_STATEMENTS="INSTALL spatial; LOAD spatial;" \
sicily_streets.parquet sicily_streets.osm.pbf lines;
@do-me
Copy link
Author

do-me commented Nov 10, 2025

Steps are very fast, run in 8.4s!

(base) ➜  osm_streets time osmium extract -b 12.2,36.5,15.8,38.8 italy.osm.pbf -o sicily.osm.pbf --overwrite
[======================================================================] 100% 
osmium extract -b 12.2,36.5,15.8,38.8 italy.osm.pbf -o sicily.osm.pbf   46.71s user 2.01s system 869% cpu 5.604 total
(base) ➜  osm_streets time osmium tags-filter sicily.osm.pbf w/highway -o sicily_streets.osm.pbf --overwrite
[======================================================================] 100% 
osmium tags-filter sicily.osm.pbf w/highway -o sicily_streets.osm.pbf   4.39s user 0.31s system 575% cpu 0.817 total
(base) ➜  osm_streets time ogr2ogr -f Parquet -oo PRELUDE_STATEMENTS="INSTALL spatial; LOAD spatial;" \
        sicily_streets.parquet sicily_streets.osm.pbf lines
Warning 6: driver OSM does not support open option PRELUDE_STATEMENTS
0...10...20...30...40...50...60...70...80...90...100 - done.
ogr2ogr -f Parquet -oo PRELUDE_STATEMENTS="INSTALL spatial; LOAD spatial;"     1.60s user 0.32s system 106% cpu 1.802 total

Or all commands chained:

(base) ➜  osm_streets time (osmium extract -b 12.2,36.5,15.8,38.8 italy.osm.pbf -o sicily.osm.pbf --overwrite; osmium tags-filter sicily.osm.pbf w/highway -o sicily_streets.osm.pbf --overwrite; ogr2ogr -f Parquet -oo PRELUDE_STATEMENTS="INSTALL spatial; LOAD spatial;" sicily_streets.parquet sicily_streets.osm.pbf lines)
[======================================================================] 100% 
[======================================================================] 100% 
Warning 6: driver OSM does not support open option PRELUDE_STATEMENTS
0...10...20...30...40...50...60...70...80...90...100 - done.
( osmium extract -b 12.2,36.5,15.8,38.8 italy.osm.pbf -o sicily.osm.pbf ;    )  1.72s user 0.33s system 24% cpu 8.473 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment