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

Upgrade titiler-pgstac #234

Closed
3 tasks done
j08lue opened this issue Oct 9, 2023 · 9 comments
Closed
3 tasks done

Upgrade titiler-pgstac #234

j08lue opened this issue Oct 9, 2023 · 9 comments
Assignees

Comments

@j08lue
Copy link

j08lue commented Oct 9, 2023

Large backlog

TiTiler-PgSTAC is now at 0.8.0 and we are still at

"titiler.pgstac==0.2.3",

This is blocking a number of features that were implemented upstream in TiTiler, which we need in VEDA, most notably

Complications

There have been some breaking API changes in TiTiler between the latest version and what we have, so any update will need to be coordinated with dependants - the VEDA Dashboard and the EO Dashboard.

Acceptance criteria

  • Mapped out breaking changes
  • Deployed to a "staging" stack for the Dashboard(s) to build against
  • Upgraded TiTiler-PgSTAC
@vincentsarago vincentsarago self-assigned this Oct 9, 2023
@vincentsarago
Copy link
Contributor

Most of the breaking changes (Some of them only concern the main application of titiler-pgstac so it might not be relevant):

  • Use /collections/{collection_id}/items/{item_id} prefix for Item endpoint.
# Before
{endpoint}/stac/info?collection=collection1&item=item1

# Now
{endpoint}/collections/collection1/items/item1/info
  • change tile url path parameter order from /tiles/{searchid}/{TileMatrixSetId}/{z}/{x}/{y} to /{searchid}/tiles/{TileMatrixSetId}/{z}/{x}/{y}
# Before
{endpoint}/mosaic/tiles/20200307aC0853900w361030/0/0/0

# Now
{endpoint}/mosaic/20200307aC0853900w361030/tiles/0/0/0
  • replace /{searchid}/{z}/{x}/{y}/assets endpoints by /{searchid}/tiles/{z}/{x}/{y}/assets

  • use /api and /api.html for documentation (instead of /openapi.json and /docs)

  • add landing page /

  • replace - by _ in query parameters

    • coord-crs -> coord_crs
    • dst-crs -> dst_crs
  • remove max_size default for mosaic's /statistics [POST] endpoint breaking change

  • add /bbox and /feature [POST] optional endpoints

anayeaye added a commit that referenced this issue Oct 17, 2023
ref #234 

This PR aims to update titiler-pgstac from version 0.2.3 to 0.8.0. Doing
so, will also update titiler, rio-tiler, morecantile, fastapi and
pydantic.

Endpoint changes 


- ~~Use `/collections/{collection_id}/items/{item_id}` prefix for Item
endpoint.~~

I was able to keep this as it was
(`{endpoint}/stac/info?collection=collection1&item=item1`)

- `post_process=` -> `algorithm=`

- change tile url path parameter order from
`/tiles/{searchid}/{TileMatrixSetId}/{z}/{x}/{y`} to
`/{searchid}/tiles/{TileMatrixSetId}/{z}/{x}/{y}`

```
# Before
{endpoint}/mosaic/tiles/20200307aC0853900w361030/0/0/0

# Now
{endpoint}/mosaic/20200307aC0853900w361030/tiles/0/0/0
```

- replace `/{searchid}/{z}/{x}/{y}/assets` endpoints by
`/{searchid}/tiles/{z}/{x}/{y}/assets`

- replace - by _ in query parameters

    - coord-crs -> coord_crs
    - dst-crs -> dst_crs

- remove `max_size` default for mosaic's `/statistics [POST]` endpoint
breaking change

- add `/bbox` and `/feature [POST]` optional endpoints
@anayeaye
Copy link
Collaborator

I created a test stack with the new titiler and a copy of the staging database that I needed for testing the veda-docs
https://test-stac.delta-backend.com/
https://test-raster.delta-backend.com/

@hanbyul-here
Copy link

hanbyul-here commented Oct 23, 2023

Adding more changes that were commented on the original PR (Thanks @anayeaye for thoroughly going through the changes!)

@anayeaye
Copy link
Collaborator

anayeaye commented Nov 6, 2023

Veda-config PR with algorithm change.

@j08lue
Copy link
Author

j08lue commented Nov 10, 2023

We need another version upgrade for rio-tiler to include this bug fix, please:

This is hopefully the last missing change to enable us to do equal-area zonal statistics. 🚀

Happening here:

@vincentsarago
Copy link
Contributor

Note:

any re-deploy will include the new rio-tiler fix (because rio-tiler is not pin to specific version 🙏)

#246 will be nice to have if we want to use the custom algorithm instead of eqa projection!

@anayeaye
Copy link
Collaborator

@j08lue @slesaad ghgc-dev(smce) and veda-dev are both running rio-tiler 6.2.6 (w/validate shape in coverage)

@j08lue
Copy link
Author

j08lue commented Nov 13, 2023

Awesome, @anayeaye and @vincentsarago, this now works:

import requests

RASTER_API_URL = "https://dev.ghg.center/api/raster"

ITEM_ASSET_URL = "s3://veda-data-store-staging/no2-monthly/OMI_trno2_0.10x0.10_202109_Col3_V4.nc.tif"

AOI = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          [
            [
              -115,
              82
            ],
            [
              -115,
              -82
            ],
            [
              -43,
              -82
            ],
            [
              -43,
              82
            ],
            [
              -115,
              82
            ]
          ]
        ],
        "type": "Polygon"
      }
    }
  ]
}

result = requests.post(
    f"{RASTER_API_URL}/cog/statistics",
    params={
        "url": ITEM_ASSET_URL,
        "dst_crs": "+proj=cea"
    },
    json=AOI["features"][0],
)
result.raise_for_status()
result.json()

and gives different results when I set dst_crs or not.

@j08lue
Copy link
Author

j08lue commented Nov 13, 2023

I can also confirm that the results of the case with +proj=cea agree with the weighted average calculated with the scientist-provided method:

image

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

No branches or pull requests

5 participants