You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "modi3011 (via GitHub)" <gi...@apache.org> on 2026/10/14 11:34:37 UTC
[PR] [GH-2409] Clip raster to the ROI extent in zonal statistics [sedona]
modi3011 opened a new pull request, #3461:
URL: https://github.com/apache/sedona/pull/3461
getStatObjects rasterized the zone at the full extent of the input raster and then read and scanned every pixel, so the cost scaled with raster size rather than with the size of the region of interest. For a small polygon on a large raster this is both slow and memory-hungry (two full-size sample arrays).
Rasterize the ROI with useGeometryExtent=true so only the window covered by the geometry is produced, and read just that window from the source band. The window's offset in the source raster is computed from pixel centres. If the window cannot be placed exactly (for example a skewed raster or a window that does not fit inside the raster), fall back to the previous full-extent path, so results are unchanged in those cases. A null rasterization result (the geometry burns no pixel) now yields an empty pixel set, matching the previous behaviour.
Statistics are unchanged: pixels are still visited in row-major order, so the output of RS_ZonalStats and RS_ZonalStatsAll is identical to before.
Tests:
- [new tests: small polygon on a larger raster, bottom-up raster, polygon that only touches the raster boundary]
- RasterBandAccessorsTest passes
Benchmark ([machine, JDK], [size] raster, ~50x50 pixel polygon): before [x] ms, after [y] ms
Closes #2409
## 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/)
- No, I haven't read it.
## Is this PR related to a ticket?
- Yes, and the PR name follows the format `[SEDONA-XXX] my subject`.
- Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #<issue_number>
- No:
- this is a documentation update. The PR name follows the format `[DOCS] my subject`
- this is a CI update. The PR name follows the format `[CI] my subject`
## What changes were proposed in this PR?
## How was this patch tested?
## Did this PR include necessary documentation updates?
- Yes, I am adding a new API. I am using the [current SNAPSHOT version number](https://github.com/apache/sedona/blob/99239524f17389fc4ae9548ea88756f8ea538bb9/pom.xml#L29) in `vX.Y.Z` format.
- Yes, I have updated the documentation.
- 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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6186743127
@modi3011 test failed
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6334968345
after reviewing this pr, i think there are a number of correctness issue of this pr. Please do not work on issues that are not marked as good first issue. Thanks.
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6283895827
and your pr does not have any test. not sure if this is expected
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "sudhamsh-git (via GitHub)" <gi...@apache.org>.
sudhamsh-git commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6261485308
Nice improvement. Rasterizing only the ROI's window instead of the whole raster means zonal stats now scale with the size of the zone rather than the raster, which is exactly what #2409 asks for. Thanks for the quick fix on the RasterizationTest cases too.
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6281067667
@modi3011 can you check your pr description? It has lots of place holder and does not make sense.
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "Mayukh-D (via GitHub)" <gi...@apache.org>.
Mayukh-D commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6311100802
Nice, the tests cover the edge cases, including the polygon only touching the boundary and the one partly outside the raster. lgtm
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "modi3011 (via GitHub)" <gi...@apache.org>.
modi3011 commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6259619463
Hi @jiayuasu. Sorry for the failing tests in the last commit. Can you please take another look at the latest commit?
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "modi3011 (via GitHub)" <gi...@apache.org>.
modi3011 commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6379975178
Thanks for taking the time to review the PR.
I know that there may be some correctness issues that need to be addressed. I’ll make sure to focus only on issues marked as good first issues and avoid working on anything outside that scope.
I’d also appreciate it if you could point out what I could have done differently while working on this PR, or any specific areas where I could improve my approach. I’d love to learn from this experience and do better in future contributions.
--
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-2409] Clip raster to the ROI extent in zonal statistics [sedona]
Posted by "modi3011 (via GitHub)" <gi...@apache.org>.
modi3011 commented on PR #3461:
URL: https://github.com/apache/sedona/pull/3461#issuecomment-6311008770
Thanks @jiayuasu for pointing this out. I apologize for the frequent changes related to the PR and the description. I've fixed the description.
I've also added tests to RasterBandAccessorsTest covering a small polygon on a larger raster (top-down and bottom-up), a polygon partly outside the raster, nodata inside the window, and a polygon that only touches the boundary. They also pass against the previous implementation, so the results are unchanged.
--
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