Skip to content

r.out.gdal: increase limit for the number of overviews - #7865

Merged
ninsbl merged 8 commits into
OSGeo:mainfrom
ninsbl:r_out_gdal_overviewlimit
Aug 29, 2026
Merged

ninsbl merged 8 commits into
OSGeo:mainfrom
ninsbl:r_out_gdal_overviewlimit

Conversation

@ninsbl

@ninsbl ninsbl commented Aug 28, 2026

Copy link
Copy Markdown
Member

For large (e.g. country-wide) datasets, having mor than 5 overviews can be beneficial for viewing exported data in other systems.
The number of overviews r.out.gdal is able to write was capped at 5 as a limit in GRASS, not GDAL.

This PR increases that limit. It is now buped to15 overviews r.out.gdal can write to the resulting file. Happy to change the number to anything > 8 which I would consider a kind of minimal limit given todays dataset sizes...

Changes are covered by a pytest.

@ninsbl
ninsbl requested review from wenzeslaus and a lite review from Copilot August 28, 2026 14:44
@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite labels Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ninsbl

ninsbl commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

I see python3-gdal is missing as dependency for the tests. OK to add it?

@ninsbl
ninsbl requested a review from metzm August 29, 2026 12:00
@github-actions github-actions Bot added windows Microsoft Windows specific CI Continuous integration labels Aug 29, 2026

@metzm metzm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No objection from my side to increase the allowed number of overviews.

The smallest possible overview has a size of 1x1. With a large number of overviews requested, it can happen that the highest levels would result in no overviews. GDAL handles that correctly and only produces overviews down to 1x1 size. That means if 15 levels are requested, it can happen that only 9 levels, as in the added test, are produced, which is correct. Please add a test using the same input raster as in the current new test, but request 15 overview levels and check that the produced number of overview levels is < 15.

There is no need to add a test in the main code for a reasonable maximum number of overviews for a given raster/region as long as this is handled by GDAL.

@metzm

metzm commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

In order to not increase the number of tests, you could also modify the newly introduced test, request 15 overviews and assert that 9 overviews are created. This ensures that more than 5 overviews are allowed and that GDAL handles an excess number of requested overview levels without error.

@metzm

metzm commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Last suggestion: increase the allowed number of overviews to 30. The technical limit is given by the GDAL API with BuildOverviews() with the const int *panOverviewList argument. The limit for 32 bit integers is 2^31 -1, thus 30 overviews with the last overview at level 2^30 is the largest technically possible number avoiding integer overflow.

@ninsbl
ninsbl enabled auto-merge (squash) August 29, 2026 17:46
@ninsbl
ninsbl merged commit 6b1ebbe into OSGeo:main Aug 29, 2026
27 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C CI Continuous integration module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite windows Microsoft Windows specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants