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

Doc: Add Python docstring for gdal.FillNodata #9867

Merged
merged 2 commits into from
May 6, 2024

Conversation

dbaston
Copy link
Member

@dbaston dbaston commented May 6, 2024

Side note, I found the first result in the example a little surprising.

@rouault
Copy link
Member

rouault commented May 6, 2024

I found the first result in the example a little surprising.

what exactly was surprising ? at first sight, that seems plausible to me

@dbaston
Copy link
Member Author

dbaston commented May 6, 2024

I would have expected the results in the two columns to be the same.

@dbaston
Copy link
Member Author

dbaston commented May 6, 2024

Disregard, I posted a different example than the one I was troubleshooting:

import numpy as np
data = np.array([[1, 1, 1, 1], [9, 9, 9, 9], [9, 9, 9, 9], [4, 4, 4, 4]], dtype=np.float32)
ds = gdal.GetDriverByName("MEM").Create("", 4, 4, eType=gdal.GDT_Float32)
ds.WriteArray(data)
mask = data != 9  # replace pixels with value = 9
mask_ds = gdal.GetDriverByName("MEM").Create("", 4, 4, eType=gdal.GDT_Byte)
mask_ds.WriteArray(mask)
gdal.FillNodata(ds.GetRasterBand(1), mask_ds.GetRasterBand(1), 5, 0)

with result

[[1.       1.       1.       1.      ]
 [2.070572 2.070572 2.070572 2.      ]
 [2.929428 2.929428 2.929428 3.      ]
 [4.       4.       4.       4.      ]]

I would have expected all columns to have the same result. But the first three columns consider values directly above and below as "top left" and "bottom left" and the values in the next column to the right as "top right" and "bottom right". In the last column, the values directly above and below are considered for all of "top left", "top right", "bottom left", and "bottom right", giving a different set of interpolation weights.

That seemed confusing, so I changed the example for the docs.

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 69.09%. remained the same
when pulling 8f39aca on dbaston:python-api-docs
into a393f0a on OSGeo:master.

@rouault rouault merged commit 65e177b into OSGeo:master May 6, 2024
34 checks passed
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

Successfully merging this pull request may close these issues.

3 participants