Conversation
Member
Author
|
@dbaston when doing so, I discovered that when calling |
edzer
commented
Sep 16, 2026
| Rcpp::NumericVector ret(ncell * g.size()); | ||
| for (int i = 0; i < (int) g.size(); i++) { | ||
| for (int j = 0; j < ncell; j++) | ||
| buf[j] = 0.0; // initialize, needed for i > 0! |
Contributor
It's actually cells outside the geometry's bounding box that keep their old value. This behavior is wrong, and a fix is in libgeos/geos#1532 Still, you may want to adjust your usage to crop the raster down to each bbox before the call. Otherwise, a lot of effort is spent copying zeros around. |
dbaston
reviewed
Sep 16, 2026
Co-authored-by: Dan Baston <dbaston@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
st_interpolate_aw()is for area-weighted interpolation, estimating attribute values from geometry set A to an arbitrary geometry set B, by using averaging (intensive variables) or summing/redistributing (extensive variables). The naive implementation computes all A-B intersections, and uses their areas for weighting. Since GEOS 3.14,GEOSGridIntersectionFractions_r(migrated from @dbaston's exactextracter) computes such weights much more efficiently in case A or B is (regularly) gridded; and tbh that is probably a very common, if not dominant, use case. The current PR implements this both forx(source geoms) being a regularly griddedstarsobject, as well asto(target geoms).The
st_interpolated_aw.stars()has been added tosfin the current CRAN release for that reason, and needs to be removed fromstars(which happened in r-spatial/stars@50ad7e8).