grass
grass copied to clipboard
r.stats: add JSON output
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.
@kritibirda26 let's pick up on r.report first ( PR: https://github.com/OSGeo/grass/pull/3033) before starting on r.stats. It should be simpler and will help figure out how to address r.stats.
Makes sense @cwhite911
I have added a comment on the r.report PR to discuss the schema further.
Welcome to Codecov :tada:
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 :open_umbrella:
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)?
Seems like it was the case..
@cwhite911 The PR is ready for review.
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?
Solved conflicts. Also renamed the test folder so it can be collected by gunittest