<div dir="ltr">Dear all,<div><br></div><div>I'm looking for a function to resample a raster from 300m to 1km by considering the mean value of pixels that are not "No Data", as GDAL Warp does. </div><div>But, in case the majority of values within the 3x3 kernel of the 300m raster are "No data", "No data" will be assigned to the resampled pixel, which is not included in the above mentioned GDAL tool.</div><div>I tried to explain the request here: <a href="https://gis.stackexchange.com/questions/366978/how-to-resample-a-raster-considering-a-minimum-number-of-valid-pixels">https://gis.stackexchange.com/questions/366978/how-to-resample-a-raster-considering-a-minimum-number-of-valid-pixels</a>]. Apparently, neither QGIS nor Gdal have the possibility to make this control on the values during the resampling. Do you know if there is an automatic way to do this?<br></div><div>In order to solve this problem, I have done this script <a href="https://gist.github.com/fgianoli/46a45c5fe042a952580947a282feedc1">https://gist.github.com/fgianoli/46a45c5fe042a952580947a282feedc1</a> to create a mask to check my results. But I'm experiencing this error 

at the end of the process, and I don't understand if my code is wrong or is a qgis setting:  (I'm running version 3.14 under Win10):<br></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>NameError: free variable 'self' referenced before assignment in enclosing scope </div><div>Traceback (most recent call last):</div><div>  File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 201, in on_complete</div><div>    self.feedback.reportError(</div><div>NameError: free variable 'self' referenced before assignment in enclosing scope</div></blockquote><div><br></div><div><br></div><div>Any suggestions?</div><div>Many thanks and kind regards,</div><div><br></div><div>Federico</div></div>