Repository navigation
r.histogram: an addon to draw a histogram based on raster values - #1904
Merged
Merged
Conversation
Addon draws a histogram of the non-NULL values in an input raster map. It exposes various matplotlib options to set bar colors (including colors based on raster color table), line width, axis labels. It complements d.histogram by allowing the user to create more print ready images, and v.histogram, which creates histograms based on attribute values of a vector layer.
correct lint error and more robust determination if region and raster extent/resolution match.
There was a problem hiding this comment.
🟡 Changes recommended
An unquoted raster name in the temporary-copy mapcalc expression can cause valid inputs to fail or silently plot incorrect values.
4 open issues
What changed in this PR
Adds r.histogram, a GRASS addon for creating customizable, print-ready histograms from raster values, complementing d.histogram and v.histogram.
Changes:
- Computes equal-width histogram bins with
r.stats, supporting cell counts and percentages. - Adds Matplotlib display and image export with raster-based colors, horizontal orientation, and formatting options.
- Provides usage examples and build definitions for Make and CMake.
| File | Description |
|---|---|
src/raster/r.histogram/r.histogram.py |
Implements histogram computation, styling, and output. |
src/raster/r.histogram/r.histogram.md |
Documents options, behavior, and examples. |
src/raster/r.histogram/r.histogram.html |
Provides the HTML manual and illustrated examples. |
src/raster/r.histogram/Makefile |
Adds the script’s Make build target. |
src/raster/r.histogram/CMakeLists.txt |
Defines CMake addon installation and documentation files. |
Review effort: Balanced
Fix string formatting in mapcalc and update documentation for raster mask functionality. Add additional documentation files for histogram. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.


Addon draws a histogram of the non-NULL values in an input raster map. It exposes various matplotlib options to set bar colors (including colors based on raster color table), line width, axis labels. It complements d.histogram by allowing the user to create more print ready images, and v.histogram, which creates histograms based on attribute values of a vector layer.