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

add statistics endpoints #347

Merged
merged 4 commits into from
Aug 2, 2021
Merged

add statistics endpoints #347

merged 4 commits into from
Aug 2, 2021

Conversation

vincentsarago
Copy link
Member

@vincentsarago vincentsarago commented Jul 27, 2021

closes #340

This PR adds 2 new endpoints per TilerFactories
GET - /statistics: get stats from a preview of a dataset
POST - /statistics: get stats from a feature covering a dataset

To Be Discussed

Per the HTML specification, list must be passed using multiple parameter (e.g p=1&p=2) and is also supported in openapi. When we started titiler we (I) didn't knew about this and used comma delimited string (e.g bidx=1,2,3) to allow list input. In the PR the statistics endpoints have 2 list inputs: c (categories) and p (percentiles). I've choose to keep the name small because those will be repeated in the query_param (e.g p=1&p=2 to define percentiles=[1, 2]).

I'm open to discuss either we should follow the spec or use comma delimited values. I've already raised this over #262 (comment)

IMO we should switch every list input to this, but as it's a breaking change I'll think starting to implement this for new QueryParameters is the safest way 🤷

Here is example of statistics result

$ curl http://127.0.0.1:8000/cog/statistics\?url\=https://rio-tiler-dev.s3.amazonaws.com/data/eu_webAligned_256px.tif&bidx=1
[
  {
    "min": 38,
    "max": 255,
    "mean": 125.75282900811122,
    "count": 262106,
    "sum": 32960571,
    "std": 36.320596765212024,
    "median": 102,
    "percentile_2": 0,
    "percentile_98": 178,
    "valid_percent": 25
  }
]

$ curl http://127.0.0.1:8000/cog/statistics\?url\=https://rio-tiler-dev.s3.amazonaws.com/data/eu_webAligned_256px.tif&bidx=1&categorical=true&c=1&c=2&c=3
[
  {
    "categories": {
      "1": 0,
      "2": 0,
      "3": 0
    },
    "valid_percent": 25
  }
]

@vincentsarago vincentsarago merged commit e8f0fd6 into master Aug 2, 2021
@vincentsarago vincentsarago deleted the StatisticsEndpoints branch August 2, 2021 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add /statistics endpoints
1 participant