Skip to content

r.volume: Add JSON support #6036

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

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

Conversation

NishantBansal2003
Copy link
Contributor

Fixes: #5949

This PR adds JSON support to the r.volume module. The JSON output looks like:

[
            {
                "category": 217,
                "average": 118.92688424466569,
                "sum": 86288827.98632812,
                "cells": 725562,
                "volume": 8628882798.632812,
                "easting": 635325,
                "northing": 221535,
            },
            {
                "category": 262,
                "average": 108.96982328824218,
                "sum": 21650560.37020111,
                "cells": 198684,
                "volume": 2165056037.020111,
                "easting": 638935,
                "northing": 222495,
            },
]

This PR includes the following changes:

  1. Adds a format option with plain, csv, and json modes for output formatting.
  2. Adds format = csv option; the -f flag is now deprecated.
  3. Adds a separator parameter to be able to change the unformatted report; If no separator is specified, the default is :; If the format is CSV, the separator is a comma.
  4. Adds a -p flag to control whether the report is printed. Currently, the report is printed by default, but this flag will be required in the future.
  5. Adds tests covering each of the new formats.
  6. Adds a Pandas example to the documentation for parsing JSON output.

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 docs markdown Related to markdown, markdown files tests Related to Test Suite CMake labels Jul 5, 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 CMake docs markdown Related to markdown, markdown files module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] JSON output to r.volume
1 participant