<div dir="ltr">Hi Andrea,<div><br></div><div>It seems to me that SAGA doesn't have this option to check the values inside a kernel. </div><div>I think the only way to do this is in more steps with an huge amount of computation time.</div><div><br></div><div>Basically, my steps now are: </div><div><br></div><div>reclassify the input raster in 1 (where my pixels have a valid value) and 0.</div><div>resampling the reclassified raster with my kernel 3x3 using the mode to obtain a mask</div><div>resampling the input raster with my 3x3 kernel using the average</div><div>multiply the mask 0-1 with my resampled raster average</div><div><br></div><div>I did these steps manually and I got a result, but if I run my script I'm obtaining the error "NameError: free variable 'self' referenced before assignment in enclosing scope" and I don't understand why.</div><div><br></div><div>Really thanks</div><div><br></div><div>Federico</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mer 8 lug 2020 alle ore 20:06 Andrea Peri <<a href="mailto:aperi2007@gmail.com">aperi2007@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Have you tried the saga -> resampling inside qgis ?<div dir="auto"><br></div><div dir="auto">A.</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il mer 8 lug 2020, 18:50 Federico Gianoli <<a href="mailto:alpacagis@gmail.com" target="_blank">alpacagis@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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" rel="noreferrer" target="_blank">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" rel="noreferrer" target="_blank">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:0px 0px 0px 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>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" rel="noreferrer" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div>
</blockquote></div>