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.univar: add JSON support #3783

Merged
merged 5 commits into from
Jul 3, 2024
Merged

Conversation

kritibirda26
Copy link
Contributor

Use parson to add json output format support to the r.univar module.

Expected JSON schema:

At the root is an array, each element of which has the stats for a given zone. The percentile option allows the user to request specific percentiles which are written for each zone object as percentile_%d keys.

[
    {
        "zone_number": <int>,
        "zone_category": <string>,
        "n": <int>,
        "null_cells": <int>,
        "cells": <int>,
        "min": <double>,
        "max": <double>,
        "range": <double>,
        "mean": <double>,
        "mean_of_abs": <double>,
        "stddev": <double>,
        "variance": <double>,
        "coeff_var": <double>,
        "sum": <double>,
        "first_quartile": <double>,
        "median": <double>,
        "third_quartile": <double>,
        "percentile_98": <double>
    }
]

Use parson to add json output format support to the r.univar module.
@github-actions github-actions bot added raster Related to raster data processing Python Related code is in Python C Related code is in C HTML Related code is in HTML module docs tests Related to Test Suite labels Jun 7, 2024
@wenzeslaus
Copy link
Member

Can you please compare this schema to what db.univar generates? Maybe they don't need to be the same, but if they are not, we need to have a good reason for that.

@kritibirda26
Copy link
Contributor Author

@wenzeslaus Can you please point me to the db.univar module, I am unable to find it.

@echoix
Copy link
Member

echoix commented Jun 7, 2024

@wenzeslaus Can you please point me to the db.univar module, I am unable to find it.

https://github.com/OSGeo/grass/tree/f13b37931af919be04fa14f392a1f9ea9aa183fd/scripts/db.univar

Copy link
Contributor

@cwhite911 cwhite911 left a comment

Choose a reason for hiding this comment

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

Update json output and tests to match v.univar.

@kritibirda26
Copy link
Contributor Author

@cwhite911 updated.

raster/r.univar/stats.c Outdated Show resolved Hide resolved
raster/r.univar/stats.c Outdated Show resolved Hide resolved
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
@nilason nilason self-requested a review July 2, 2024 14:32
@nilason nilason self-requested a review July 2, 2024 14:32
@echoix echoix added this to the 8.5.0 milestone Jul 2, 2024
Copy link
Contributor

@cwhite911 cwhite911 left a comment

Choose a reason for hiding this comment

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

@kritibirda26 nice work!

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

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

Code looks good to me, I haven't tested though.

@echoix echoix merged commit 71ed433 into OSGeo:main Jul 3, 2024
26 checks passed
@kritibirda26 kritibirda26 deleted the add-json-to-r-univar branch July 6, 2024 13:19
a0x8o pushed a commit to a0x8o/grass that referenced this pull request Jul 23, 2024
* Add JSON support to r.univar

Use parson to add json output format support to the r.univar module.

* Apply suggestions from code review

---------

Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
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 docs HTML Related code is in HTML 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.

5 participants