Skip to content

feat: Single-COG/item reads on native grid#79

Open
Berhinj wants to merge 9 commits into
developmentseed:mainfrom
Berhinj:singe-item-untouched
Open

feat: Single-COG/item reads on native grid#79
Berhinj wants to merge 9 commits into
developmentseed:mainfrom
Berhinj:singe-item-untouched

Conversation

@Berhinj

@Berhinj Berhinj commented Jun 29, 2026

Copy link
Copy Markdown

Motivation

I believe people would benefit from loading a single scene untouched on original grid, reusing lazycogs' existing pieces but still getting an xarray out of it.

Summary

Adds lazycogs.open_cog and lazycogs.open_item to read a single COG or STAC item at its native grid (no reprojection), reusing existing obstore/async-geotiff/rustac components.

@Berhinj Berhinj mentioned this pull request Jul 2, 2026

@hrodmn hrodmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Berhinj thanks for opening this! The open_cog/open_cog_async methods will be useful. Looking at your example notebook makes me think that an open_item method would also be useful where you provide an entire STAC item and a list of bands. We would need to check the extent/shape of each geotiff asset to make sure they are equal but it could be a nice complement to the open_cog option for cases where there are multiple bands.

Comment thread pdm.lock Outdated
Comment thread pyproject.toml Outdated
Comment thread test.ipynb Outdated
Berhinj added 4 commits July 13, 2026 12:08
- Introduced a new helper function `_write_synthetic_cog` to streamline the creation of synthetic COGs with customizable parameters such as size, native resolution, and band count.
- Updated the `synthetic_cog` fixture to utilize the new helper function, maintaining the original properties while allowing for more flexibility.
- Introduction open_item
- Undo lock and pyproject changes
@Berhinj Berhinj changed the title Draft: single-COG reads at native resolution feat: single-COG reads at native resolution Jul 14, 2026
@github-actions github-actions Bot added the feat label Jul 14, 2026
@Berhinj Berhinj changed the title feat: single-COG reads at native resolution feat: Single-COG/item reads on native grid Jul 14, 2026
@Berhinj

Berhinj commented Jul 14, 2026

Copy link
Copy Markdown
Author

@hrodmn thanks for your interest, I've put on the work and done a clean implementation now, tell me what you think

@Berhinj
Berhinj requested a review from hrodmn July 14, 2026 08:41
Comment thread src/lazycogs/_single.py
Comment on lines +124 to +126
reprojection. Source ``nodata`` is set as ``_FillValue`` and any
``scale``/``offset`` as ``scale_factor``/``add_offset`` so rioxarray's
``mask_and_scale`` decoding applies them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can check with @hrodmn but I think this project is using Markdown formatting, which means you only need one backtick. Did AI write these docs?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes I rely a lot on on claude opus as everyone for routines, especially for docstring and tests, for code like this one I still wrote a good chunk myself and made sure to review all ai written code, it is true though that I'm spending as much effort on reviewing ai written docstring

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

regarding the backtick, indeed in markdown it is single tick but in docstring it is two, tbh I copied the existing style from the other .py files you have which is already using double tick, example: https://github.com/Berhinj/lazycogs/blob/47ae2b6e0c43db3db7d899fc7e564e7746a86f8f/scripts/prepare_benchmark_data.py#L69-L70

Comment thread src/lazycogs/_single.py
) -> DataArray:
"""Open one COG at native resolution as an ``(band, y, x)`` DataArray.

Async variant of :func:`open_cog` for use inside a running event loop.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto we're not using Sphinx docstring formatting in this project

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

correct, it is not compatible with mkdocs, I was copying the style from the existing functions of the repo - example: https://github.com/Berhinj/lazycogs/blob/47ae2b6e0c43db3db7d899fc7e564e7746a86f8f/src/lazycogs/_grid.py#L55

happy to correct it but the rest of the repo is full of it, could we keep it in a seperate pr?

Comment thread src/lazycogs/_single.py
@Berhinj

Berhinj commented Jul 15, 2026

Copy link
Copy Markdown
Author

@kylebarron your comments on docstring formatting are valid but they're everywhere in the repo, it is an existing issue, I believe they should be addressed in a different PR globally instead - which I did here #87

@Berhinj
Berhinj requested a review from kylebarron July 15, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants