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

Allow generic_image reader to set fill value on reading #2928

Open
strandgren opened this issue Oct 11, 2024 · 1 comment · May be fixed by #2940
Open

Allow generic_image reader to set fill value on reading #2928

strandgren opened this issue Oct 11, 2024 · 1 comment · May be fixed by #2940
Assignees
Labels
bug component:readers enhancement code enhancements, features, improvements

Comments

@strandgren
Copy link
Collaborator

strandgren commented Oct 11, 2024

While looking into #2923 I went through the generic_image reader code. All the images with A channel are converted to floats and NaNs are placed to the no data pixels. If there's no A but the image has a nodatavals metadata item present and nodata_handling is set to "fill_value" the image is kept as integer data. I'm not sure PNG supports the no data value (or fill value).

Maybe the generic_image reader should have a feature to force a fill_value that would replace the A band whether there is a fill value in the original image or not.

Originally posted by @pnuu in #2897 (comment)

@pnuu
Copy link
Member

pnuu commented Oct 14, 2024

I did some format testing.

Saving to PNG with fill_value=0 using Satpy and reading the image back with rasterio, we can see that nodatavals are (None, None, None).

I think what we'd need is a set_fill_value kwarg that is used to set the nodatavals. A single value or a tuple. Then in .get_dataset() -> ._mask_image_data() we'd need to handle discarding of the A band for the case where set_fill_value is given.

@pnuu pnuu self-assigned this Oct 18, 2024
@pnuu pnuu added bug enhancement code enhancements, features, improvements labels Oct 18, 2024
@pnuu pnuu linked a pull request Oct 18, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component:readers enhancement code enhancements, features, improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants