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.stats: add JSON output #3884

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

kritibirda26
Copy link
Contributor

Using parson, add JSON output support to r.stats module.

For cell stats, the output looks like:

[
    {
        "labels": [
            {
                "value": 1,
                "label": "CARY",
                "name": "towns"
            },
            {
                "value": 55,
                "label": "",
                "name": "urban"
            }
        ],
        "area": 23475900,
        "count": 234759,
        "percent": 11.651235678463038
    },
    {
        "labels": [
            {
                "value": 2,
                "label": "GARNER",
                "name": "towns"
            },
            {
                "value": 55,
                "label": "",
                "name": "urban"
            }
        ],
        "area": 14142700,
        "count": 141427,
        "percent": 7.0191102718021128
    },
    {
        "labels": [
            {
                "value": 3,
                "label": "APEX",
                "name": "towns"
            },
            {
                "value": 55,
                "label": "",
                "name": "urban"
            }
        ],
        "area": 1519700,
        "count": 15197,
        "percent": 0.75423659414805311
    }
]

For raw stats, the output looks like:

[
    {
        "easting": 639315,
        "northing": 228495,
        "col": 932,
        "row": 1,
        "labels": [
            {
                "value": 6,
                "label": "RALEIGH-WEST",
                "name": "towns"
            },
            {
                "value": 55,
                "label": "",
                "name": "urban"
            }
        ]
    },
    {
        "easting": 639325,
        "northing": 228495,
        "col": 933,
        "row": 1,
        "labels": [
            {
                "value": 6,
                "label": "RALEIGH-WEST",
                "name": "towns"
            },
            {
                "value": 55,
                "label": "",
                "name": "urban"
            }
        ]
    }
]

The labels array has the numerical value, categorical name, and the name of the inputs associated with the stat. I am unsure if these fields can be named better.

Once the JSON format is decided, I will add tests and update the documentation as well.

@github-actions github-actions bot added raster Related to raster data processing C Related code is in C module labels Jun 18, 2024
@cwhite911
Copy link
Contributor

cwhite911 commented Jun 18, 2024

@kritibirda26 let's pick up on r.report first ( PR: #3033) before starting on r.stats. It should be simpler and will help figure out how to address r.stats.

@kritibirda26
Copy link
Contributor Author

Makes sense @cwhite911

@kritibirda26
Copy link
Contributor Author

I have added a comment on the r.report PR to discuss the schema further.

Copy link

codecov bot commented Jun 28, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@echoix
Copy link
Member

echoix commented Jun 28, 2024

The codecov shouldn't be sending comments, it was explicitly disabled in config. Is it because the branch doesn't include the config file (not enough updated from main)?

@echoix
Copy link
Member

echoix commented Jun 28, 2024

Seems like it was the case..

@echoix echoix changed the title r.stats: add json output r.stats: add JSON output Jul 10, 2024
@github-actions github-actions bot added the Python Related code is in Python label Aug 12, 2024
@kritibirda26
Copy link
Contributor Author

@cwhite911 The PR is ready for review.

@github-actions github-actions bot added HTML Related code is in HTML docs labels Aug 16, 2024
@echoix
Copy link
Member

echoix commented Aug 16, 2024

Before merging, can you make sure that your PRs are either formatted according to clang format 18 (changed 2 days ago), or merged from main?

@neteler neteler added this to the 8.5.0 milestone Oct 24, 2024
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
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants