NASA-IMPACT / NASA-IMPACT/veda-data

Fix floating point EPSG codes in all collections

Open
#81 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jupyter Notebook
Stars
9
Forks
1
Avg merge
1d 9m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with notebooks/tutorials/gif-generation.ipynb and reproduce the stackstac.stack failure for OMI_trno2_0.10x0.10_201601_Col3_V4.nc. Trace the collection data containing proj:epsg=4326.0 back to its origin, then inspect all collections for floating-point EPSG values. Done means no floating-point EPSG codes remain and the ticket fixing the faulty data origin is referenced.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.