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

Support STAC 1.0 - part 0 #96

Merged
merged 14 commits into from
Jun 25, 2021

Conversation

TomAugspurger
Copy link
Collaborator

This is a precursor PR to supporting STAC 1.0. It just updates the tests to use files from the PyStac repo, rather than sat-stac.

A followup PR will update the URLs to point to the STAC 1.0.0 versions of those files while updating the code to use PyStac 1.0.

The first two commits are just #94 and can be ignored. fbf84a2 has the actual changes.

Tom Augspurger added 3 commits June 20, 2021 10:01
This prepares for STAC 1.0 support by updating the tests to use files
from the PyStac repo. Supporting STAC 1.0 will involve updating to the
latest versions of those files.

col passing

wip
@scottyhq
Copy link
Collaborator

Thanks for starting this @TomAugspurger ! I left some comments trying to figure out whether to use external examples for testing, or if we might want to put our own example STAC=1.0 examples in this repository (with valid asset / subcatalog links)

@TomAugspurger
Copy link
Collaborator Author

I think having our own STAC catalogs, with just the data we need for testing, makes sense. Now that we're at STAC 1.0, this seems more feasible. I'll look into that.

@TomAugspurger
Copy link
Collaborator Author

OK, updated to use some local files, rather than opening STAC objects from remote URLs.

I think the stack_bands might be a bit under-tested, but hopefully I got it right. The items I'm using came from the Planetary Computer, so URLs to data files in blob storage have to be signed to download. I don't think we want to do that in our unit tests, but here's a manual tests:

In [1]: import rasterio

In [2]: import pystac, planetary_computer, intake

In [3]: item = planetary_computer.sign_assets(pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a/items/S2B_MSIL2A_20210610T115639_N0212_R066_T33
   ...: XWC_20210613T190000.SAFE"))

In [5]: intake_item = intake.open_stac_item(item)

In [6]: ds = intake_item.stack_bands(["B02", "B03"])().to_dask()

In [7]: ds
Out[7]:
<xarray.DataArray (band: 2, y: 10980, x: 10980)>
dask.array<concatenate, shape=(2, 10980, 10980), dtype=uint16, chunksize=(1, 10980, 10980), chunktype=numpy.ndarray>
Coordinates:
  * band     (band) int64 1 1
  * y        (y) float64 8.3e+06 8.3e+06 8.3e+06 ... 8.19e+06 8.19e+06 8.19e+06
  * x        (x) float64 5e+05 5e+05 5e+05 ... 6.098e+05 6.098e+05 6.098e+05
Attributes:
    transform:      (10.0, 0.0, 499980.0, 0.0, -10.0, 8300040.0)
    crs:            +init=epsg:32633
    res:            (10.0, 10.0)
    is_tiled:       1
    nodatavals:     (nan,)
    scales:         (1.0,)
    offsets:        (0.0,)
    AREA_OR_POINT:  Area

Copy link
Collaborator

@scottyhq scottyhq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @TomAugspurger ! Would be happy to merge this as is. We can add some additional tests in future PRs and hopefully release 1.0.0 shortly after pystac 1.0.0 ?

@TomAugspurger
Copy link
Collaborator Author

TomAugspurger commented Jun 24, 2021 via email

@TomAugspurger TomAugspurger merged commit 8daedf2 into intake:main Jun 25, 2021
@TomAugspurger TomAugspurger deleted the fix/pystac-1.0-part0 branch June 25, 2021 11:51
This was referenced Jun 25, 2021
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.

2 participants