Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show warning if float raster is used as input in zonal histogram algorithm (fix #30822) #60212

Merged
merged 3 commits into from
Jan 23, 2025

Conversation

alexbruy
Copy link
Contributor

@alexbruy alexbruy commented Jan 22, 2025

Description

Zonal Histogram algorithm from Processing is not suitable for running against floating point raster values with lots of decimal places and produces output with lots of attributes.

If user uses a floating-point raster as an input the algorithm will now show a warning and suggest to run Reclassify by table or Round raster tools first.

Fixes #30822.

@alexbruy alexbruy requested review from nirvn and nyalldawson January 22, 2025 10:31
@github-actions github-actions bot added this to the 3.42.0 milestone Jan 22, 2025
@alexbruy
Copy link
Contributor Author

@nirvn what do you think about this, maybe it would be enough just to extend algorithm help without introducing rounding of the input?

Copy link

github-actions bot commented Jan 22, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 69f7317)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 69f7317)

@nirvn
Copy link
Contributor

nirvn commented Jan 22, 2025

@alexbruy , I feel when it comes to float, an histogram doesn't make tons of sense even with rounding. Feels more like they should go through a reclassify by table alg. first to define their bins. Or, as you suggested, rounding (I guess if you'd have a temperature raster, some rounding to 0 decimal could give you some interesting 1-degree breakdown of temperature :) ).

In any case, I am wondering if the proper fix here would simply to through users a warning about float not being friendly to histogram and encourage them to use round raster or reclassify by table algs instead of adding a decimal rounding parameter in this alg.

I've got no strong feelings about it though, if you do like the parameter approach, I'll +1.

@alexbruy alexbruy force-pushed the processing-zonal-histogram-precision branch from eef20ce to 9342506 Compare January 22, 2025 14:06
@alexbruy alexbruy changed the title round float values in zonal histogram algorithm to prevent creation of the output with too many attributes (fix #30822) show warning if float raster is used as input in zonal histogram algorithm (fix #30822) Jan 22, 2025
@alexbruy
Copy link
Contributor Author

@nirvn I'm also more in favor of warning, as this is more in line with Processing approach. One can create a model/script if necessary. PR updated to show a warning.

@alexbruy alexbruy added Processing Relating to QGIS Processing framework or individual Processing algorithms backport queued_ltr_backports Queued Backports backport release-3_40 labels Jan 23, 2025
@alexbruy alexbruy merged commit 836a197 into qgis:master Jan 23, 2025
42 checks passed
@alexbruy alexbruy deleted the processing-zonal-histogram-precision branch January 23, 2025 07:49
@qgis-bot
Copy link
Collaborator

The backport to queued_ltr_backports failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 93425063f33... show warning when floating-point raster is used as an input in zonal
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging src/analysis/processing/qgsalgorithmzonalhistogram.cpp
Auto-merging src/analysis/processing/qgsalgorithmzonalhistogram.h
CONFLICT (content): Merge conflict in src/analysis/processing/qgsalgorithmzonalhistogram.h

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-60212-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 93425063f3322ea59be965848c7bd99728b722c6,5717abd1c8f6c2d83398f75461a0ca58240b5b5f,69f7317d9ef95cc84f01026f27bd0333b0c90caf
# Push it to GitHub
git push --set-upstream origin backport-60212-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports

Then, create a pull request where the base branch is queued_ltr_backports and the compare/head branch is backport-60212-to-queued_ltr_backports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports backport release-3_40 failed backport The automated backport attempt failed, needs a manual backport Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zonal histogram unusable results if input raster has many decimal places
3 participants