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

Add indexes option to img.render() ? #344

Open
chrieke opened this issue Feb 5, 2021 · 1 comment
Open

Add indexes option to img.render() ? #344

chrieke opened this issue Feb 5, 2021 · 1 comment

Comments

@chrieke
Copy link
Contributor

chrieke commented Feb 5, 2021

Using img.render() with an ImageData.data array with too many bands fails with
CPLE_NotSupportedError: PNG driver doesn't support 5 bands. Must be 1 (grey), 2 (grey+alpha), 3 (rgb) or 4 (rgba) bands.

Example:

src_path = "https://naipblobs.blob.core.windows.net/naip/v002/al/2019/al_60cm_2019/30087/m_3008701_ne_16_060_20191115.tif"
with COGReader(src_path) as cog:
    img = cog.preview()    
    print(img.data.shape)  # >>> (4, 1024, 892)

img.render()

Reading all bands and later visualizing a band subset (without mutating the array) seems like a common usecase. Would propose to add an indexes parameter to .render(), so that specific bands can be selected for the vizualization.

Happy to make a PR, but wanted to check first if there is a better solution or this is not intended etc.

@vincentsarago
Copy link
Member

vincentsarago commented Feb 5, 2021

@chrieke I think this is a nice feature.

The render function (

def render(
) is quite old and complexe, feel free to start a WIP pr and then we can jump on if you have question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants