temporal: add granularity and start options to t.rast.univar #3042#7244
Open
selma-Bentaiba wants to merge 1 commit intoOSGeo:mainfrom
Open
temporal: add granularity and start options to t.rast.univar #3042#7244selma-Bentaiba wants to merge 1 commit intoOSGeo:mainfrom
selma-Bentaiba wants to merge 1 commit intoOSGeo:mainfrom
Conversation
ninsbl
requested changes
Apr 3, 2026
Member
ninsbl
left a comment
There was a problem hiding this comment.
I did not go through everything in detail yet. Here are some comments...
|
|
||
| # When the user asks for granularity, we group maps into time windows | ||
| # and later feed each group as a comma-joined list to r.univar. | ||
| # No new rasters written to disk — that's the whole point of this feature. |
Member
There was a problem hiding this comment.
Suggested change
| # No new rasters written to disk — that's the whole point of this feature. |
| granule_groups = None | ||
| if granularity and rows: | ||
| # Snap the start of the first window to the requested granularity | ||
| # unless the user gave an explicit start time |
Member
There was a problem hiding this comment.
I would argue against adding a start option.
When the granularity option is added, a sampling option would make sense, but start less so. Start can be picked up from first map in series selected by temporal where...
See
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.
We're trying to solve #3042 by adding native temporal aggregation support to t.rast.univar. This implementation allows users to compute univariate statistics over grouped time windows (granules) without the overhead of creating intermediate raster data via t.rast.aggregate.
Implementation Details
Parameter Addition: Added granularity and start options to the t.rast.univar CLI.
Library Logic: Updated the grass.temporal library (specifically print_gridded_dataset_univar_statistics) to handle map grouping based on the provided granularity.
Efficiency: The module now identifies all maps within a temporal granule and passes them as a comma-separated list to the r.univar backend, leveraging its native multi-map support.
Verification:

Added a comprehensive test class TestRasterUnivarGranularity to the existing testsuite.
Manually verified (see screenshot) that a 4-map STRDS correctly aggregates into 2-month granules with accurate mathematical results (Means of 15 and 35) and no additional raster creation.