Rasterization: remaining differences from GDAL on grid-aligned inputs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- computer-graphics, data
Research direction
Start with the grid-aligned cases in this issue, then inspect RasterConstructorsTest.testAsRasterWithRaster and the rasteralgebraTest case using test5.tiff. Replay the cases against GDAL 3.12.4 and rasterio 1.5.1, decide which differences Sedona should follow or document, and add each decided case to test_rasterize_parity.py.
Written by the indexing model from the issue text.
Description
#3425 (#3428) aligns points, grid-aligned polygon edges and boundary-only contact with GDAL's half-open cells. A grid-aligned comparison corpus, replayed against GDAL 3.12.4 (rasterio 1.5.1), still shows the differences below. All of them exist on master already; none were introduced by #3428. Each needs a decision on whether Sedona should follow GDAL.
Unless noted, the grid is 8x8 unit pixels, north-up, origin (0, 8): RS_MakeEmptyRaster(1, 'd', 8, 8, 0, 8, 1, -1, 0, 0, 0). Cells are (column, row).
1. allTouched = false: pixel centres exactly on a polygon edge
POLYGON ((2.5 5.5, 4.5 5.5, 4.5 3.5, 2.5 3.5, 2.5 5.5)) puts pixel centres exactly on all four edges.
- GDAL: columns 3-4, rows 2-4
- Sedona: columns 2-4, rows 3-4
The scanline fill resolves a centre on an edge differently from GDAL.
2. allTouched = true: a cell touched only at a polygon vertex
POLYGON ((1 7, 5 7, 3 4, 1 7)): the apex (3, 4) is the top-left corner of cell (3,4), which the polygon touches only at that point.
- GDAL burns (3,4)
- Sedona does not
#3120 chose not to follow this. The comment in RasterConstructorsTest.testAsRasterWithRaster describes it as a quirk of GDAL's scan order. GDAL does not burn such cells in every orientation (the #3120 cases match), so this is slope- or direction-dependent on GDAL's side.
3. Lines with allTouched = false: an endpoint on a grid line
| Geometry | GDAL all_touched=False |
GDAL all_touched=True |
Sedona (both) |
|---|---|---|---|
LINESTRING (1 5, 6 5) (along a row line) |
columns 1-6 on row 3 | columns 1-5 | columns 1-5 |
LINESTRING (0 7, 0 2) (along the left edge) |
rows 1-6 in column 0 | rows 1-5 | rows 1-5 |
GDAL's non-all-touched line burner also burns the cell after an endpoint that lies on a grid line. Sedona uses one exact traversal for both modes, matching all_touched=True.
4. allTouched = true: a steep edge passing exactly through lattice corners
The zone in rasteralgebraTest "RS_ZonalStats - Raster with no data" (test5.tiff, 0.25-degree grid):
- Sedona counts 14366 with
allTouched = true - GDAL counts 14357
The nine extra cells lie along the left edge, which has slope 19/5 and passes exactly through a lattice corner every 5 columns / 19 rows. They are cells (3,179), (8,160), (13,141), ... (43,27). With allTouched = false there are ten similar centre-on-edge differences.
5. Pixel sizes with no exact binary representation (expected, probably no action)
On a 1/3600-degree grid, a coordinate that lies on a grid line is resolved by GDAL in floating point and by Sedona with the exact decimal arithmetic it uses to snap extents. For example, on the tile at origin (-180 + 822/3600, 60 - 546/3600), POINT (-179.77083333333334 59.84736111111111):
- GDAL: (2,3)
- Sedona: (3,3)
Both burn exactly one cell. Matching GDAL bit for bit would mean reproducing its internal arithmetic, which is not a stable target: plain double arithmetic and GDAL's inverse geotransform each match GDAL on some of these cases and not others.
Suggested next steps
- Decide 1-3 (follow GDAL, or document the difference).
- Look at 4, which looks like a traversal or fill tie at exact lattice crossings.
- Add each decided case to
test_rasterize_parity.py.
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 787
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 51
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/sedona
-
Snowflake ST_Distance and ST_HausdorffDistance throw NullPointerException on an empty geometryPossibly taken @jiayuasu claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 3/5 1-2 days Newbie friendliness 74/100
apache/sedona#3364 · 1 comment ·
Maintainers usually reply within 1 day
-
Clearing NoData on one raster band changes another band's MapAlgebra resultsMay be free again A pull request for this issue was closed without being merged. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
apache/sedona#3324 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
RS_ZonalStats line rois: all_touched is ignored, and the default rule burns every traversed cellOpen
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
Flight SQL JDBC parses boolean properties case-sensitively, silently disabling TLS for useEncryption=TRUEPossibly taken @Arawoof06 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
apache/arrow-java#1357 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
apache/rocketmq-dashboard#6610 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MetricsHub/metricshub-community#1396 ·
Maintainers usually reply within 1 day
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
dependabot/dependabot-core#16547 ·
Maintainers usually reply within 1 day
-
Citationcount column sorts alphabetically instead of numericallyPossibly taken @kpunia306 claimed this today. Openstatus: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JabRef/jabref#17459 · 4 comments ·
Maintainers usually reply within 1 day