Skip to content

r.resamp.stats: Fix quantile option being truncated to an integer - #7791

Open
HUN-sp wants to merge 1 commit into
OSGeo:mainfrom
HUN-sp:fix-resamp-stats-quantile
Open

r.resamp.stats: Fix quantile option being truncated to an integer#7791
HUN-sp wants to merge 1 commit into
OSGeo:mainfrom
HUN-sp:fix-resamp-stats-quantile

Conversation

@HUN-sp

@HUN-sp HUN-sp commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Here's a GitHub-ready PR description:

Summary

quantile is stored as a double, but its value was parsed using atoi(), causing any value less than 1.0 to be truncated to 0. As a result, c_quant() always received 0 as the requested quantile, returning the minimum value. This meant that method=quantile effectively behaved as method=minimum, and the quantile option had no effect.

Verification

Verified on the nc_spm_08_grass7 dataset with res=100:

Comparison | Difference -- | -- quantile=0.5 vs. minimum | 0 ... 0 (identical) quantile=0.9 vs. minimum | 0 ... 0 (identical) quantile=0.5 vs. median | -21.67 ... 0 (expected to be 0)

Fix

Replace atoi() with atof() so fractional quantile values are parsed correctly.

This matches the implementation used by other GRASS modules exposing the same option, including:

  • r.neighbors

  • r.series

  • r3.neighbors

Notes

Found while reviewing #7044 and submitted as a separate PR, as requested, to keep the fix independent.

The quantile variable is a double, but its value was parsed with atoi, so
any quantile below 1.0 became 0 and method=quantile returned the minimum
regardless of the requested quantile. Use atof, as r.neighbors, r.series
and r3.neighbors already do for the same option.
@github-actions github-actions Bot added raster Related to raster data processing C Related code is in C module labels Jul 31, 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 module raster Related to raster data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant