ProjectPythia / landsat-ml-cookbook

Machine learning on Landsat satellite data using open source tools
https://projectpythia.org/landsat-ml-cookbook/
Apache License 2.0
11 stars 4 forks source link

Issue on page /notebooks/3.0_Spectral_Clustering_PC.html #11

Closed iuryt closed 1 year ago

iuryt commented 1 year ago

When I try to run

ds_2017 = odc.stac.stac_load(
    [item],
    bands=bands.common_name.values,
    bbox=bbox,
    chunks={},  # <-- use Dask
).isel(time=0)

it returns

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[23], line 1
----> 1 ds_2017 = odc.stac.stac_load(
      2     [item],
      3     bands=bands.common_name.values,
      4     bbox=bbox,
      5 ).isel(time=0)

File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/odc/stac/_load.py:494, in load(items, bands, groupby, resampling, dtype, chunks, pool, crs, resolution, anchor, geobox, bbox, lon, lat, x, y, like, geopolygon, progress, fail_on_error, stac_cfg, patch_url, preserve_original_order, **kw)
    476 gbox = output_geobox(
    477     _parsed,
    478     bands=bands,
   (...)
    490     y=y,
    491 )
    493 if gbox is None:
--> 494     raise ValueError("Failed to auto-guess CRS/resolution.")
    496 if chunks is not None:
    497     chunk_shape = _resolve_chunk_shape(gbox, chunks)

ValueError: Failed to auto-guess CRS/resolution.

Any idea what I should do?

If I do

epsg = item.properties["proj:epsg"]
ds_2017 = odc.stac.stac_load(
    [item],
    bands=bands.common_name.values,
    bbox=bbox,
    crs=f"EPSG:{epsg}",
    resolution=10
).isel(time=0)

it works, but I don't know how to automate the resolution guess.

droumis commented 1 year ago

hmm I can't reproduce.

Has anything been changed before this line or are you running the notebook for the first time?

What version of odc-stac are you using? It works with 0.3.5 for me.

How do I get the version? `conda activate landsat-ml-cookbook` `conda list odc-stac`

Either way, the resolution of most Landsat 8 bands is 30m and can be found automatically from the gsd property like this:

ds_2017_resx = odc.stac.stac_load(
    [item],
    bands=bands.common_name.values,
    bbox=bbox,
    crs=f"EPSG:{item.properties['proj:epsg']}",
    resolution=item.properties["gsd"]
).isel(time=0)
droumis commented 1 year ago

closing, as the comment above provides the workaround