Skip to content

[DOCS] Add blog post: reading OSM PBF into Sedona - #3160

Merged
jiayuasu merged 4 commits into
apache:masterfrom
jiayuasu:blog/osm-pbf-reader
Jul 24, 2026
Merged

[DOCS] Add blog post: reading OSM PBF into Sedona#3160
jiayuasu merged 4 commits into
apache:masterfrom
jiayuasu:blog/osm-pbf-reader

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Jul 24, 2026

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

  • No: this is a documentation update. The PR name follows the format [DOCS] my subject

What changes were proposed in this PR?

A new blog post introducing the OSM PBF reader (osmpbf format): reading raw OpenStreetMap .osm.pbf extracts into a Sedona DataFrame with no conversion step. The reader currently has no dedicated tutorial or blog page, so this fills a docs gap.

  • One-line read of a .osm.pbf extract; the raw OSM element model (nodes / ways / relations) as a single table
  • Nodes → points via ST_Point (POI examples)
  • Assembling way LineStrings from ordered node refs — posexplode + join + ordered rebuild, with a figure explaining the pattern
  • Road stats over the reconstructed lines (ST_LengthSpheroid per highway class)
  • Map freshness/churn analysis via the timestamp/version metadata fields, with a note that public Geofabrik extracts strip user/uid/changeset
  • A distributed-scale section: single-file byte-range splitting across the cluster (the format is splittable), object-storage reads, and the refs → coordinates assembly as an ordinary distributed join
  • Three self-contained SVG figures (cover, way-assembly explainer, scale/parallel-decode diagram)

How was this patch tested?

  • Every query in the post was executed against Apache Sedona (PySpark, current snapshot jars) using the bundled Monaco extract (spark/common/src/test/resources/osmpbf/monaco-latest.osm.pbf); the console output shown in the post is the real output, so readers can reproduce it verbatim.
  • The site was built with mkdocs serve and the rendered post verified: both figures load, code blocks highlight, and the page renders under the blog index.
  • All SVG figures validated as well-formed XML; pre-commit hooks pass on the changed files.

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

jiayuasu added 3 commits July 24, 2026 01:45
Walks through reading raw .osm.pbf into a Sedona DataFrame with the osmpbf format: nodes to points, assembling way LineStrings from ordered node refs (posexplode + join), tag filtering and spheroid road-length stats, plus edit-history analysis via timestamp/version. All examples run against the bundled Monaco extract. Adds two self-contained SVG figures.
Add a section covering single-file splitting across the cluster, object-storage reads, and the refs-to-coordinates assembly as a distributed join.
New figure: one planet file split into byte-range blocks, decoded in parallel, landing as one Sedona DataFrame. Cover tagline and chip now carry the distributed-scale message.
@jiayuasu
jiayuasu requested a review from Copilot July 24, 2026 09:10
@jiayuasu
jiayuasu marked this pull request as ready for review July 24, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Apache Sedona blog post that introduces the native osmpbf (OpenStreetMap PBF) reader and demonstrates turning raw OSM elements (nodes/ways/relations) into usable geometries and spatial analytics in Sedona/Spark SQL.

Changes:

  • Adds a new blog post walkthrough for reading .osm.pbf directly into a Sedona DataFrame and querying it with Spatial SQL.
  • Includes examples for node→point construction, way→LineString reconstruction via ordered node refs, and basic measurement/temporal metadata queries.
  • Adds three accompanying SVG figures used by the post (cover + two explanatory diagrams).

Reviewed changes

Copilot reviewed 1 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/blog/posts/osm-pbf-reader.md New blog post documenting end-to-end .osm.pbf ingestion and analysis patterns in Sedona Spark.
docs/blog/posts/osm-pbf-reader-cover.svg New cover illustration for the blog post.
docs/blog/posts/osm-pbf-reader-assembly.svg Diagram explaining ordered way-ref expansion and geometry reconstruction.
docs/blog/posts/osm-pbf-reader-scale.svg Diagram explaining splittable/parallel decoding and scaling characteristics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +107 to +124
way_pts AS ( -- one row per (way, vertex), ordered
SELECT w.id AS way_id, w.tags AS tags, w.pos AS seq, n.lon, n.lat
FROM (SELECT id, tags, posexplode(refs) AS (pos, ref)
FROM osm WHERE kind = 'way') w
JOIN nodes n ON n.id = w.ref
)
SELECT way_id,
any_value(tags)['highway'] AS highway,
ST_GeomFromText(concat('LINESTRING(',
array_join(
transform(array_sort(collect_list(struct(seq, lon, lat))),
x -> concat(x.lon, ' ', x.lat)),
', '),
')')) AS geom
FROM way_pts
GROUP BY way_id
HAVING count(*) >= 2 AND any_value(tags)['highway'] IS NOT NULL
""")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2b156ed. The highway tag is now extracted before the join with the filter pushed ahead of it, grouping is on (way_id, highway), and the LineString is built with ST_MakeLine over the sorted point array. Verified against the Monaco extract: identical results (3334 ways, 163.9 km, same per-class breakdown).

Extract the highway tag before the join and group by (way_id, highway) instead of using the non-deterministic any_value aggregate; assemble the LineString with ST_MakeLine over the sorted point array instead of WKT concatenation. Verified against the Monaco extract: identical results (3334 ways, 163.9 km, same per-class table).
@jiayuasu
jiayuasu merged commit 90f6cb1 into apache:master Jul 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants