Skip to content

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

@chrieke

Description

@chrieke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions