@@ -599,15 +599,18 @@ void wrapper_VSIGetMemFileBuffer(const char *utf8_path, GByte **out, vsi_l_offse
599599 def ReadAsMaskedArray (self, xoff=0 , yoff=0 , win_xsize=None, win_ysize=None,
600600 buf_xsize=None, buf_ysize=None, buf_type=None,
601601 resample_alg=gdalconst.GRIORA_NearestNeighbour ,
602+ mask_resample_alg=gdalconst.GRIORA_NearestNeighbour ,
602603 callback=None,
603604 callback_data=None):
604605 " " "
605606 Read a window of this raster band into a NumPy masked array.
606607
607608 Values of the mask will be ``True`` where pixels are invalid.
609+
610+ Starting in GDAL 3.11, if resampling (``buf_xsize`` != ``xsize``, or ``buf_ysize`` != ``ysize``) the mask
611+ band will be resampled using the algorithm specified by ``mask_resample_alg``.
608612
609- See :py:meth:`ReadAsArray` for a description of arguments.
610-
613+ See :py:meth:`ReadAsArray` for a description of additional arguments.
611614 " " "
612615 import numpy
613616 array = self.ReadAsArray (xoff=xoff, yoff=yoff,
@@ -625,7 +628,7 @@ void wrapper_VSIGetMemFileBuffer(const char *utf8_path, GByte **out, vsi_l_offse
625628 win_ysize=win_ysize,
626629 buf_xsize=buf_xsize,
627630 buf_ysize=buf_ysize,
628- resample_alg=resample_alg ).astype (bool )
631+ resample_alg=mask_resample_alg ).astype (bool )
629632 else :
630633 mask_array = None
631634 return numpy.ma .array (array, mask=mask_array)
@@ -1113,13 +1116,19 @@ CPLErr ReadRaster1( double xoff, double yoff, double xsize, double ysize,
11131116 def ReadAsMaskedArray (self, xoff=0 , yoff=0 , xsize=None, ysize=None,
11141117 buf_xsize=None, buf_ysize=None, buf_type=None,
11151118 resample_alg=gdalconst.GRIORA_NearestNeighbour ,
1119+ mask_resample_alg=gdalconst.GRIORA_NearestNeighbour ,
11161120 callback=None,
11171121 callback_data=None,
11181122 band_list=None):
11191123 " " "
11201124 Read a window from raster bands into a NumPy masked array.
11211125
1122- Parameters are the same as for :py:meth:`ReadAsArray`.
1126+ Values of the mask will be ``True`` where pixels are invalid.
1127+
1128+ If resampling (``buf_xsize`` != ``xsize``, or ``buf_ysize`` != ``ysize``) the mask band will be resampled
1129+ using the algorithm specified by ``mask_resample_alg``.
1130+
1131+ See :py:meth:`ReadAsArray` for a description of additional arguments.
11231132 " " "
11241133
11251134 import numpy as np
@@ -1140,7 +1149,7 @@ CPLErr ReadRaster1( double xoff, double yoff, double xsize, double ysize,
11401149 xoff=xoff, yoff=yoff,
11411150 win_xsize=xsize, win_ysize=ysize,
11421151 buf_xsize=buf_xsize, buf_ysize=buf_ysize,
1143- resample_alg=gdalconst. GRIORA_Mode ) != 255
1152+ resample_alg=mask_resample_alg ) != 255
11441153 for band in band_list]
11451154
11461155 return np.ma .masked_array (arr, np.vstack (masks))
0 commit comments