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

Fix floating point EPSG codes in all collections #81

Open
2 tasks
j08lue opened this issue Oct 4, 2023 · 0 comments
Open
2 tasks

Fix floating point EPSG codes in all collections #81

j08lue opened this issue Oct 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@j08lue
Copy link
Contributor

j08lue commented Oct 4, 2023

For example the code in our demo notebook https://github.com/NASA-IMPACT/veda-docs/blob/main/notebooks/tutorials/gif-generation.ipynb that attempts to load the item OMI_trno2_0.10x0.10_201601_Col3_V4.nc with stackstac fails:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[7], line 1
----> 1 da = stackstac.stack(search.item_collection(), gdal_env=gdal_env)
      2 da = da.assign_coords({"time": pd.to_datetime(da.start_datetime)})
      3 da

File /srv/conda/envs/notebook/lib/python3.10/site-packages/stackstac/stack.py:287, in stack(items, assets, epsg, resolution, bounds, bounds_latlon, snap_bounds, resampling, chunksize, dtype, fill_value, rescale, sortby_date, xy_coords, properties, band_coords, gdal_env, errors_as_nodata, reader)
    280 if sortby_date is not False:
    281     plain_items = sorted(
    282         plain_items,
    283         key=lambda item: item["properties"].get("datetime", "") or "",
    284         reverse=sortby_date == "desc",
    285     )
--> 287 asset_table, spec, asset_ids, plain_items = prepare_items(
    288     plain_items,
    289     assets=assets,
    290     epsg=epsg,
    291     resolution=resolution,
    292     bounds=bounds,
    293     bounds_latlon=bounds_latlon,
    294     snap_bounds=snap_bounds,
    295 )
    296 arr = items_to_dask(
    297     asset_table,
    298     spec,
   (...)
    306     errors_as_nodata=errors_as_nodata,
    307 )
    309 return xr.DataArray(
    310     arr,
    311     *to_coords(
   (...)
    320     name="stackstac-" + dask.base.tokenize(arr),
    321 )

File /srv/conda/envs/notebook/lib/python3.10/site-packages/stackstac/prepare.py:166, in prepare_items(items, assets, epsg, resolution, bounds, bounds_latlon, snap_bounds)
    158     elif out_epsg != asset_epsg:
    159         raise ValueError(
    160             f"Cannot pick a common CRS, since assets have multiple CRSs: asset {id!r} of item "
    161             f"{item_i} {item['id']!r} is in EPSG:{asset_epsg}, "
    162             f"but assets before it were in EPSG:{out_epsg}.\n\n"
    163             "Please specify a CRS with the `epsg=` argument."
    164         )
--> 166 assert isinstance(out_epsg, int), f"`out_epsg` not found. {out_epsg=}"
    167 # ^ because if it was None initially, and we didn't error out in the above check, it's now always set
    169 if bounds_latlon is not None and out_bounds is None:

AssertionError: `out_epsg` not found. out_epsg=4326.0

Resulting from proj:epsg being a floating point value.

image

Acceptance criteria

  • No more floating point EPSG codes
  • Referenced ticket that fixes the origin of the faulty data
@j08lue j08lue added the bug Something isn't working label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant