You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "jiayuasu (via GitHub)" <gi...@apache.org> on 2026/09/27 08:06:18 UTC
[PR] [GH-3414] Rasterize points by grid index and bound writes to the raster grid [sedona]
jiayuasu opened a new pull request, #3416:
URL: https://github.com/apache/sedona/pull/3416
## Did you read the Contributor Guide?
- Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/)
## Is this PR related to a ticket?
- Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #3414
## What changes were proposed in this PR?
Fixes the crashes in #3414, all in `Rasterization.java`:
- **`rasterizePoint` walks by grid index.** It used to walk the extent by repeatedly adding `scaleX` / `scaleY` to a world coordinate while counting the pixel index separately. With a pixel size that has no exact double representation (e.g. 1/3600 degree), the coordinate drifts, the loop takes one step too many, and JAI's `setSample` (no bounds check) writes past the buffer (`Index 65536`, `Index -246`). It now iterates integer column/row ranges clamped to the grid and builds each cell envelope from its index on the reference raster's grid, so the cell tested and the cell written can no longer disagree, and cropped output resolves boundary contacts the same way as full-extent output. The geometry is prepared once for the per-cell tests.
- **Non-polygonal clips.** A polygon that only grazes the raster clips to a point, a line or a `GeometryCollection`, which `rasterizePolygon` cast to `Polygon` (`ClassCastException`). Such clips now go through `rasterizeGeometry`, keeping only their polygonal parts unless `allTouched` is set, since a point or line left by the clip covers no pixel centre. `rasterizePolygon` becomes private, and the unused `throws FactoryException` is dropped from `rasterizeGeometry` / `rasterizeGeometryCollection`.
- **`fillPolygon`** clamps fill ranges to the grid and discards an unpaired scanline intercept that lands past it, instead of writing out of bounds.
This does not yet restore the second row for a point exactly on a grid line with `allTouched` (it burns `(10,0)` without `(10,1)`); that is #3415, in a follow-up PR stacked on this one.
## How was this patch tested?
- New tests in `RasterizationTest` for every case in #3414: corner point, point on the row 0/1 line, a zone grazing the tile's corner (both `allTouched` values, and through `getZonalStatsAll`), a clip that becomes a `GeometryCollection`, the unpaired intercept, and cropped vs full-extent consistency. On master: 19 run, 5 errors (the AIOOBE and `ClassCastException` cases above). With the change: 19 run, 0 failures.
- All tests under `org.apache.sedona.common.raster`: 500 run, 0 failures. Spark `rasteralgebraTest` and `rasterIOTest`: 192 passed, 0 failed.
- A randomized probe (seed 444) of 1,200 points exactly on grid lines and corners of 1/3600 degree tiles: master has 2 crashes and 29 wrong-row burns with full-extent output and 65 crashes with cropped output; with this change, 0 crashes and 0 wrong-row burns.
- A 211-case parity corpus against GDAL (rasterio) rasterization: 0 mismatches before and after.
## Did this PR include necessary documentation updates?
- No, this PR does not affect any public API so no need to change the documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-3414] Rasterize points by grid index and bound writes to the raster grid [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #3416:
URL: https://github.com/apache/sedona/pull/3416
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org