[QGIS-Developer] QGIS Script Error and Resampling Tool

Federico Gianoli alpacagis at gmail.com
Wed Jul 8 09:50:00 PDT 2020


Dear all,

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.
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.
I tried to explain the request here:
https://gis.stackexchange.com/questions/366978/how-to-resample-a-raster-considering-a-minimum-number-of-valid-pixels].
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?
In order to solve this problem, I have done this script
https://gist.github.com/fgianoli/46a45c5fe042a952580947a282feedc1 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):

NameError: free variable 'self' referenced before assignment in enclosing
scope
Traceback (most recent call last):
  File
"C:/OSGEO4~1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py",
line 201, in on_complete
    self.feedback.reportError(
NameError: free variable 'self' referenced before assignment in enclosing
scope



Any suggestions?
Many thanks and kind regards,

Federico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200708/fcda6773/attachment.html>


More information about the QGIS-Developer mailing list