Skip to content

Terra > 1.9.1 enables more efficient aggregation tables#4

Merged
njhenry merged 3 commits intomainfrom
bugfix/terra-1.9
Mar 10, 2026
Merged

Terra > 1.9.1 enables more efficient aggregation tables#4
njhenry merged 3 commits intomainfrom
bugfix/terra-1.9

Conversation

@njhenry
Copy link
Contributor

@njhenry njhenry commented Mar 10, 2026

terra v.1.9.1, released on March 6, 2026, included a bugfix for terra::extract(SpatVector, SpatRaster, fun = 'table', weights = FALSE) (changelog).

The build_aggregation_table() function was using a workaround for this terra::extract() bug and can now rely on the fixed function to create a pixel-to-polygon aggregation table directly. This fix also specifies terra >= 1.9.1 as a package dependency (see the DESCRIPTION file).

This PR resolves issue #3, as the build_aggregation_table() function will work with terra >= 1.9 moving forward.


Note

Medium Risk
Changes core aggregation-table generation logic and now depends on specific terra behavior; results/performance should be validated across representative polygon/raster inputs.

Overview
Updates the package to v1.1.1 and requires terra (>= 1.9.1).

Reworks build_aggregation_table() to build pixel-to-polygon area-fraction tables via a single terra::extract(..., fun='table', exact=TRUE, ID=TRUE) call instead of per-polygon cropping/masking and the calculate_pixel_fractions_single_polygon() helper (which is removed along with its export/man page). Adds a small verbose message when polygons are dropped by cropping to the raster extent.

Written by Cursor Bugbot for commit a329480. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@njhenry njhenry merged commit d5f304d into main Mar 10, 2026
2 checks passed
@njhenry njhenry deleted the bugfix/terra-1.9 branch March 10, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant