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

r.category: Add color option #5011

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NishantBansal2003
Copy link
Contributor

Enhancement: Add Color Option to Category Output

Fixes: #4071

Overview

This PR introduces a new color option for r.category, allowing users to retrieve category colors alongside labels. This enhancement is useful for visualization workflows where knowing both the category label and its associated color is important.

Changes Made

  • Added a color option that allows specifying the output format:
    • none (default) – No color output.
    • rgb – Outputs colors in rgb(r, g, b) format.
    • hex – Outputs colors in #RRGGBB format.
    • triplet – Outputs colon-separated R:G:B values.
  • Updated PLAIN output format to include color:
    1 trees, very green rgb(68, 1, 84)
    2 water, very deep rgb(253, 231, 37)
    
  • Updated JSON output format to include color:
    [
        {
            "category": 1,
            "description": "trees, very green",
            "color": "rgb(68, 1, 84)"
        },
        {
            "category": 2,
            "description": "water, very deep",
            "color": "rgb(253, 231, 37)"
        }
    ]

Testing & Validation

  • Existing feature tests were taken from the r.category doctest file.
  • New feature tests for the color option have been added at the end.

Signed-off-by: Nishant Bansal <[email protected]>
@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 labels Jan 30, 2025
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 Python Related code is in Python raster Related to raster data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] r.category: add color option
1 participant