RS_PixelAsPoint raises out of grid where RS_PixelAsCentroid and RS_PixelAsPolygon extrapolate
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
The issue is in common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java. Look at getPixelAsPoint and change it to call RasterUtils.getWorldCornerCoordinates instead of getWorldCornerCoordinatesWithRangeCheck. Update the test in common/src/test/java/org/apache/sedona/common/raster/FunctionsTest.java to expect the extrapolated point, not an exception. Then update the documentation for RS_PixelAsPoint to match the other functions.
Written by the indexing model from the issue text.
Description
Expected behavior
RS_PixelAsPoint, RS_PixelAsCentroid and RS_PixelAsPolygon are one family — the same grid coordinate interpreted as a corner, a centre and a footprint — so they should agree on what an out-of-grid coordinate means.
Actual behavior
Only RS_PixelAsPoint rejects one. On a 2×3-pixel raster at (100, 500) with Sedona 1.9.1:
RS_PixelAsPoint(rast, 1, 1) -> POINT (100 500)
RS_PixelAsPoint(rast, 0, 0) -> IndexOutOfBoundsException:
Specified pixel coordinates (0, 0) do not lie in the raster
RS_PixelAsCentroid(rast, 0, 0) -> POINT (99 501.5)
RS_PixelAsPolygon(rast, 0, 0) -> POLYGON ((98 503, 100 503, 100 500, 98 500, 98 503))
The two siblings extrapolate along the geotransform without complaint. Note the polygon's first corner, (98 503): that is exactly the point RS_PixelAsPoint(0, 0) refuses to return. The value is already computed and returned by a sibling function on the same input — only this one entry point declines to hand it over.
This is documented, so it reads as deliberate rather than accidental, but the docs state the inconsistency plainly:
RS_PixelAsPoint: "If the pixel coordinates specified do not exist in the raster (out of bounds), RS_PixelAsPoint throws an IndexOutOfBoundsException."RS_PixelAsPolygonandRS_PixelAsCentroid: "IfcolXandrowYare out of bounds for the raster, they are interpolated assuming the same skew and translate values."
Cause
One call site in common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java. getPixelAsPoint uses the range-checking helper:
Point2D point2D = RasterUtils.getWorldCornerCoordinatesWithRangeCheck(raster, colX, rowY);
while getPixelAsPolygon uses the unchecked one:
Point2D point2D1 = RasterUtils.getWorldCornerCoordinates(raster, colX, rowY);
and getPixelAsCentroid delegates to getPixelAsPolygon, inheriting the unchecked behaviour. getWorldCornerCoordinatesWithRangeCheck (common/src/main/java/org/apache/sedona/common/utils/RasterUtils.java) has exactly one caller — getPixelAsPoint.
Proposed fix
Drop the range check so getPixelAsPoint matches its siblings, extrapolating along the geotransform. That direction is the non-breaking one: it turns an exception into a value, where the reverse would break existing RS_PixelAsCentroid/RS_PixelAsPolygon callers who rely on extrapolation today.
That would mean:
getPixelAsPointcallsRasterUtils.getWorldCornerCoordinates, leavinggetWorldCornerCoordinatesWithRangeCheckunused (remove it, or keep it if another caller is planned).testPixelAsPointOutOfBoundsincommon/src/test/java/org/apache/sedona/common/raster/FunctionsTest.javacurrently pins the exception, and would assert the extrapolated point instead.- The
RS_PixelAsPointdoc line changes to match the wording already used by the other two.
I am happy to open the PR if the direction sounds right. The alternative — making all three raise — is defensible on the grounds that an out-of-grid coordinate is usually a caller error, but it is a breaking change for two functions rather than a widening of one, and it would leave RS_PixelAsPolygon unable to return a footprint it can compute perfectly well.
For cross-implementation context: SedonaDB extrapolates for all three, so aligning this way would also close a divergence between the two engines.
- 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
-
Difficulty 5/5 Over a week Newbie friendliness 45/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
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
apache/rocketmq-dashboard#6610 ·
Maintainers usually reply within 3 days
-
`RedisList.reversed()` view returns an empty `range` and `trim` removes all elementsPossibly taken @CCCLL claimed this today. Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-data-redis#3461 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
javapathfinder/jpf-core#649 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
devops-thiago/ThrillhouseBot#1093 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
wimdeblauwe/htmx-spring-boot#205 ·