Skip to content

[GH-1272] Return the containing pixel from ST_Pixelize for sub-pixel geometries - #3484

Open
Mayukh-D wants to merge 2 commits into
apache:masterfrom
Mayukh-D:GH-1272-pixelize-small-geometries
Open

Mayukh-D wants to merge 2 commits into
apache:masterfrom
Mayukh-D:GH-1272-pixelize-small-geometries

Conversation

@Mayukh-D

@Mayukh-D Mayukh-D commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

ST_Pixelize traces lines and polygon rings with Bresenham's algorithm, which draws a segment's start pixel but not its end. When every vertex of a geometry falls in the same pixel, every segment draws nothing and the expression fails on assert(pixels.size() > 0).

Now:

  • a line or polygon that traces to no pixels returns the one pixel that contains it
  • collections (including the Multi* types) are pixelized member by member, so a GeometryCollection no longer fails with a MatchError
  • empty geometries return no pixels instead of failing

Geometries that span several pixels are traced exactly as before. VizTestBase now calls super.beforeAll(), so the viz suites register Sedona's SQL functions themselves instead of relying on another suite running first.

How was this patch tested?

New cases in PixelizeTest for tiny lines and polygons, collections and empty geometries. Ran the viz tests on Spark 3.5 / Scala 2.12 and Spark 4.1 / Scala 2.13, and compared the old and new code on 3,000 random shapes: everything that pixelized before gives the same pixels.

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

Assisted by Claude Code

…pixel geometries

ST_Pixelize traced lines and polygon rings with Bresenham's algorithm, which
draws a segment's start pixel but not its end pixel. When every vertex of a
geometry fell in the same pixel, every segment drew nothing, and the
expression failed on `assert(pixels.size() > 0)`.

A line or polygon that traces to no pixels now returns the single pixel
that contains it. Collections, including the Multi* types, are pixelized
member by member, so a GeometryCollection no longer fails with a
MatchError and each member keeps its own pixel. Empty geometries return no
pixels instead of failing.

Geometries spanning several pixels are traced exactly as before.

VizTestBase now calls super.beforeAll(), so the viz suites register
Sedona's SQL functions themselves instead of relying on an earlier suite
having done it.

Generated-by: Claude Code (Claude Opus 5.5)
…y geometries

Generated-by: Claude Code (Claude Opus 5.5)
@Mayukh-D
Mayukh-D requested a review from jiayuasu as a code owner October 19, 2026 13:14

This branch has not been deployed

No deployments
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.

ST_Pixelize small polygon error

3 participants