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

Paging for collections? #154

Open
ateucher opened this issue Apr 8, 2024 · 3 comments
Open

Paging for collections? #154

ateucher opened this issue Apr 8, 2024 · 3 comments

Comments

@ateucher
Copy link

ateucher commented Apr 8, 2024

Describe the requested improvement
There are items_next() and items_fetch() methods for doc_items objects. The STAC API supports pagination for collections in the same way as for items. It would be great to add _next() and _fetch() methods for collections as well. We could add doc_collections methods to items_next() and items_fetch() generics, or write collections_next() and collections_fetch() generics/methods for doc_collections objects.

Associated rstac API function
In practice, the implementation would look something like this:

stac("https://cmr.earthdata.nasa.gov/stac/LPCLOUD") |> 
    collections() |> 
    get_request() |> 
    collections_next()

Additional context
The NASA STAC API has many collections endpoints using this paging functionality: https://cmr.earthdata.nasa.gov/stac/LPCLOUD.

I would be happy to draft a pull request if you think this is in scope.

@robbibt
Copy link

robbibt commented May 8, 2024

@ateucher This would be fantastic! Python's pystac_client handles pagination automatically, and it would be fantastic to have it in rstac too

@rolfsimoes
Copy link
Contributor

Thank you for your suggestion.

We have implemented the collections_next() and collections_fetch() methods.

These changes are in the b-1.0.1 branch and they will be released soon on CRAN.
In the meantime, you can install the development version from GitHub to use these new features right away.
Here’s how you can do it using the remotes package:

# Install the remotes package if you haven't already
install.packages("remotes")

# Install the development version of rstac from GitHub
remotes::install_github("brazil-data-cube/rstac@b-1.0.1")

These functions are similar to the existing items_next() and items_fetch() methods.

Here’s an example of how to use them:

library("rstac")

# Example usage
stac("https://cmr.earthdata.nasa.gov/stac/LPCLOUD") |>
  collections() |>
  get_request() |>
  collections_fetch()

We would greatly appreciate any feedback you have. If you encounter any issues or have further suggestions, please let us know.

Best regards,
Rolf

@ateucher
Copy link
Author

Oh that's fantastic! Apologies I didn't get to this, very happy to see it!

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

3 participants