Re: [QGIS-Developer] QGIS Script Error and Resampling Tool

2020-07-08 Thread Federico Gianoli
Hi Andrea,

It seems to me that SAGA doesn't have this option to check the values
inside a kernel.
I think the only way to do this is in more steps with an huge amount of
computation time.

Basically, my steps now are:

reclassify the input raster in 1 (where my pixels have a valid value) and 0.
resampling the reclassified raster with my kernel 3x3 using the mode to
obtain a mask
resampling the input raster with my 3x3 kernel using the average
multiply the mask 0-1 with my resampled raster average

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.

Really thanks

Federico

Il giorno mer 8 lug 2020 alle ore 20:06 Andrea Peri 
ha scritto:

> Have you tried the saga -> resampling inside qgis ?
>
> A.
>
>
> Il mer 8 lug 2020, 18:50 Federico Gianoli  ha
> scritto:
>
>> 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
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] QGIS Script Error and Resampling Tool

2020-07-08 Thread Andrea Peri
Have you tried the saga -> resampling inside qgis ?

A.


Il mer 8 lug 2020, 18:50 Federico Gianoli  ha scritto:

> 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
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] QGIS Script Error and Resampling Tool

2020-07-08 Thread Federico Gianoli
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
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer