-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Python bindings: Add Dataset.ReadAsMaskedArray #12172
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
base: master
Are you sure you want to change the base?
Conversation
xoff=xoff, yoff=yoff, | ||
win_xsize=xsize, win_ysize=ysize, | ||
buf_xsize=buf_xsize, buf_ysize=buf_ysize, | ||
resample_alg=gdalconst.GRIORA_Mode) != 255 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps indicate in the doc that when downsampling the mask resampling algorithm is Mode (ie majority) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documented this and also changed behavior of Band.ReadAsMaskedArray
to match.
Hmm, I'm not sure how my tests were passing locally before. Right now I'm puzzled by
|
I believe this is due to: https://github.com/OSGeo/gdal/blob/master/gcore/overview.cpp#L4453 / https://github.com/OSGeo/gdal/blob/master/gcore/overview.cpp#L5798 |
I don't think GRA_Mode downscaling works for NoData mask bands. If I'm following the code right, it performs a downscaled read from the parent band (using GRA_Mode, and excluding NoData pixels) and then sets all valid pixels to 255. Which is different from performing a full resolution read on the parent, setting valid pixels to 255, and then downscaling. |
yes the logic I pointed out where the mask band of the mask band is the mask band itself should probably be modified for Mode, and just get the GetMaskBand() of the mask band, which would be a AllValid mask band |
I don't see either of these lines hit in this case. The issue I see is gdal/gcore/gdalnodatamaskband.cpp Lines 404 to 407 in bfb3825
where a downscaled read is performed from the parent band, and the result reclassified to 0/255. To get a correct result for All this said, the current behavior of |
Resolves #12005