@@ -599,15 +599,18 @@ void wrapper_VSIGetMemFileBuffer(const char *utf8_path, GByte **out, vsi_l_offse
599
599
def ReadAsMaskedArray (self, xoff=0 , yoff=0 , win_xsize=None, win_ysize=None,
600
600
buf_xsize=None, buf_ysize=None, buf_type=None,
601
601
resample_alg=gdalconst.GRIORA_NearestNeighbour ,
602
+ mask_resample_alg=gdalconst.GRIORA_NearestNeighbour ,
602
603
callback=None,
603
604
callback_data=None):
604
605
" " "
605
606
Read a window of this raster band into a NumPy masked array.
606
607
607
608
Values of the mask will be ``True`` where pixels are invalid.
609
+
610
+ If resampling (``buf_xsize`` != ``xsize``, or ``buf_ysize`` != ``ysize``) the mask band will be resampled
611
+ using the algorithm specified by ``mask_resample_alg``.
608
612
609
- See :py:meth:`ReadAsArray` for a description of arguments.
610
-
613
+ See :py:meth:`ReadAsArray` for a description of additional arguments.
611
614
" " "
612
615
import numpy
613
616
array = self.ReadAsArray (xoff=xoff, yoff=yoff,
@@ -625,7 +628,7 @@ void wrapper_VSIGetMemFileBuffer(const char *utf8_path, GByte **out, vsi_l_offse
625
628
win_ysize=win_ysize,
626
629
buf_xsize=buf_xsize,
627
630
buf_ysize=buf_ysize,
628
- resample_alg=resample_alg ).astype (bool )
631
+ resample_alg=mask_resample_alg ).astype (bool )
629
632
else :
630
633
mask_array = None
631
634
return numpy.ma .array (array, mask=mask_array)
@@ -1113,13 +1116,19 @@ CPLErr ReadRaster1( double xoff, double yoff, double xsize, double ysize,
1113
1116
def ReadAsMaskedArray (self, xoff=0 , yoff=0 , xsize=None, ysize=None,
1114
1117
buf_xsize=None, buf_ysize=None, buf_type=None,
1115
1118
resample_alg=gdalconst.GRIORA_NearestNeighbour ,
1119
+ mask_resample_alg=gdalconst.GRIORA_NearestNeighbour ,
1116
1120
callback=None,
1117
1121
callback_data=None,
1118
1122
band_list=None):
1119
1123
" " "
1120
1124
Read a window from raster bands into a NumPy masked array.
1121
1125
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.
1123
1132
" " "
1124
1133
1125
1134
import numpy as np
@@ -1140,7 +1149,7 @@ CPLErr ReadRaster1( double xoff, double yoff, double xsize, double ysize,
1140
1149
xoff=xoff, yoff=yoff,
1141
1150
win_xsize=xsize, win_ysize=ysize,
1142
1151
buf_xsize=buf_xsize, buf_ysize=buf_ysize,
1143
- resample_alg=gdalconst. GRIORA_Mode ) != 255
1152
+ resample_alg=mask_resample_alg ) != 255
1144
1153
for band in band_list]
1145
1154
1146
1155
return np.ma .masked_array (arr, np.vstack (masks))
0 commit comments