You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not completely sure this is actually a problem in pystac (vs maybe the projection extension or another associated package), but I do know that downgrading from pystac==1.12 to pystac==1.11 was a successful workaround. In a conda environment created with this: mamba create -n pystac_prob_min python=3.11 pystac-client odc-stac shapely, running the following code will cause a ValueError.
importpystac_clientfromodcimportstacfromdatetimeimportdatetimeasdtfromshapely.geometryimportPointdefget_stac_items(x_coord: float, y_coord: float) ->pystac_client.item_search.ItemSearch:
location_point=Point(x_coord, y_coord)
collection='sentinel-2-l2a'start_date=None# earliest availableend_date=dt.today().strftime("%Y-%m-%d")
# get a pystac client going to search the imagesclient=pystac_client.Client.open("https://earth-search.aws.element84.com/v1")
# From all days available with less than 5% cloud cover, get the 5# least cloudy days.search_results=client.search(
collections=[collection],
intersects=location_point,
datetime=[start_date, end_date],
query=["eo:cloud_cover<5"],
sortby=["+properties.eo:cloud_cover"],
max_items=5,
)
returnsearch_resultsif__name__=='__main__':
# Jalama beach pointx, y= (-120.510536, 34.510536)
# Get some itemssearch_results=get_stac_items(x, y)
ds=stac.load(
search_results.items(),
bands=['swir16'],
chunks=dict(time=1, x=5490, y=5490),
)
print(ds)
Here's the traceback:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/jkibele/repos/land-mask-lambda/pystac_bug_min_example.py", line 35, in <module>
ds = stac.load(
^^^^^^^^^^
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/odc/stac/_stac_load.py", line 360, in load
_parsed = list(parse_items(items, cfg=stac_cfg, md_plugin=md_plugin))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/odc/stac/_mdtools.py", line 745, in parse_items
proc.update(item)
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/odc/stac/_mdtools.py", line 574, in update
self._bootstrap(item)
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/odc/stac/_mdtools.py", line 557, in _bootstrap
_, band2grid = compute_eo3_grids(data_bands)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/odc/stac/_mdtools.py", line 317, in compute_eo3_grids
geoboxes = dicttoolz.valmap(asset_geobox, assets)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/toolz/dicttoolz.py", line 85, in valmap
rv.update(zip(d.keys(), map(func, d.values())))
File "/Users/jkibele/miniforge3/envs/pystac_prob_min/lib/python3.11/site-packages/odc/stac/_mdtools.py", line 277, in asset_geobox
raise ValueError(
ValueError: The asset must have the following fields (from the projection extension): shape, transform, and one of an epsg, wkt2, or projjson
python-BaseException
If I force pystac==1.11 (instead of version 1.12) by creating another conda env with this command: mamba create -n pystac_prob_fix python=3.11 pystac=1.11 pystac-client odc-stac shapely and run the same code, then I get the expected result which is an xarray Dataset containing the retrieved items.
The problem seems to have something to do with how the projection extension is working (the proj crs_string is coming back as None), but I haven't had time to dig any further at this point.
After poking around a bit more, I found #1503. It looks very likely that was the cause of my problem. It seems that you fine folks have already found and fixed this issue, and I missed it when searching the issues earlier. Sorry to raise a false alarm, and thanks for all your work.
No worries at all, and thanks for the detailed report. I'm hoping to release the bugfix (and probably an implementation for #1504, which should also help) early this week.
I am not completely sure this is actually a problem in
pystac
(vs maybe the projection extension or another associated package), but I do know that downgrading frompystac==1.12
topystac==1.11
was a successful workaround. In a conda environment created with this:mamba create -n pystac_prob_min python=3.11 pystac-client odc-stac shapely
, running the following code will cause aValueError
.Here's the traceback:
If I force
pystac==1.11
(instead of version 1.12) by creating another conda env with this command:mamba create -n pystac_prob_fix python=3.11 pystac=1.11 pystac-client odc-stac shapely
and run the same code, then I get the expected result which is an xarray Dataset containing the retrieved items.The problem seems to have something to do with how the projection extension is working (the proj
crs_string
is coming back asNone
), but I haven't had time to dig any further at this point.It seems that at least one other person was having the same problem: https://www.reddit.com/r/pythonhelp/comments/1i8uvgq/problem_in_odcstac_when_reading_geospacial/. (I'm the one that commented there, not the original poster).
The text was updated successfully, but these errors were encountered: