Skip to content

r.stats.quantile: Add JSON support #6007

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

Merged
merged 1 commit into from
Jul 2, 2025

Conversation

NishantBansal2003
Copy link
Contributor

Fixes: #5951

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

[
	{
		"category": 27511,
		"percentiles": [
			{
				"percentile": 50,
				"value": 139.62598419189453
			}
		]
	},
	{
		"category": 27513,
		"percentiles": [
			{
				"percentile": 50,
				"value": 143.7049102783203
			}
		]
	},
	{
		"category": 27518,
		"percentiles": [
			{
				"percentile": 50,
				"value": 122.53437805175781
			}
		]
	}
]

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 -t flag is now deprecated.
  3. If no separator is specified, the default is :; If the format is CSV, the separator is a comma.
  4. Adds tests covering each of the new formats.
  5. Adds a Python example to the documentation for parsing JSON output.

@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 1, 2025
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Thank you!

@petrasovaa petrasovaa merged commit 170d644 into OSGeo:main Jul 2, 2025
27 checks passed
@github-actions github-actions bot added this to the 8.5.0 milestone Jul 2, 2025
@petrasovaa petrasovaa moved this to Done in GRASS JSON Outputs Jul 2, 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
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feat] Add JSON output to r.stats.quantile
2 participants