Spatial convolution: ZeroDivisionError: float division by zero

Issue #1319 resolved
Former user created an issue

EnMAP-Box version: Multiple, including current release and most recent test version

QGIS version: Both current release (3.24.2) and long-term release (3.22.6)

Compiled against Qt: 5.15.2

Compiled against GDAL/OGR: 3.4.2

OS Version: Windows 11

Active python plugins: enmapboxplugin; Planet_Explorer; QuickOSM

Started up ENMap box for the first time in over a month, and getting this error with any type of Spatial Convolution and any raster. Tried with the most recent release and long-term release of QGIS (which is the only thing that’s changed since it was working) with the most recent release of EnMAP box, as well as a couple of test versions.

Algorithm 'Spatial convolution Gaussian filter' starting…

Input parameters:

{ 'interpolate' : True, 'kernel' : 'from astropy.convolution import Gaussian2DKernel\nkernel = Gaussian2DKernel(x_stddev=1, y_stddev=1)', 'normalize' : False, 'outputRaster' : 'TEMPORARY_OUTPUT', 'raster' : 'C:/Users/J/local_drive_work/dzanga_sangha/03_predictors/03_02_protected/protected_before_2005_binary.tif' }

Filter kernel [9, 9]: [[1.7910529328280185e-08, 5.931152735254121e-07, 7.225623237724323e-06, 3.238299669088984e-05, 5.3390535453281935e-05, 3.238299669088984e-05, 7.225623237724323e-06, 5.931152735254121e-07, 1.7910529328280185e-08], [5.931152735254121e-07, 1.964128034639744e-05, 0.0002392797792004706, 0.0010723775711956546, 0.0017680517118520167, 0.0010723775711956546, 0.0002392797792004706, 1.964128034639744e-05, 5.931152735254121e-07], [7.225623237724323e-06, 0.0002392797792004706, 0.0029150244650281935, 0.013064233284684921, 0.021539279301848634, 0.013064233284684921, 0.0029150244650281935, 0.0002392797792004706, 7.225623237724323e-06], [3.238299669088984e-05, 0.0010723775711956546, 0.013064233284684921, 0.05854983152431917, 0.09653235263005391, 0.05854983152431917, 0.013064233284684921, 0.0010723775711956546, 3.238299669088984e-05], [5.3390535453281935e-05, 0.0017680517118520167, 0.021539279301848634, 0.09653235263005391, 0.15915494309189535, 0.09653235263005391, 0.021539279301848634, 0.0017680517118520167, 5.3390535453281935e-05], [3.238299669088984e-05, 0.0010723775711956546, 0.013064233284684921, 0.05854983152431917, 0.09653235263005391, 0.05854983152431917, 0.013064233284684921, 0.0010723775711956546, 3.238299669088984e-05], [7.225623237724323e-06, 0.0002392797792004706, 0.0029150244650281935, 0.013064233284684921, 0.021539279301848634, 0.013064233284684921, 0.0029150244650281935, 0.0002392797792004706, 7.225623237724323e-06], [5.931152735254121e-07, 1.964128034639744e-05, 0.0002392797792004706, 0.0010723775711956546, 0.0017680517118520167, 0.0010723775711956546, 0.0002392797792004706, 1.964128034639744e-05, 5.931152735254121e-07], [1.7910529328280185e-08, 5.931152735254121e-07, 7.225623237724323e-06, 3.238299669088984e-05, 5.3390535453281935e-05, 3.238299669088984e-05, 7.225623237724323e-06, 5.931152735254121e-07, 1.7910529328280185e-08]]

Convolve raster

Create Raster [10549x11537x1](Float32) -co INTERLEAVE=BAND COMPRESS=LZW TILED=YES BIGTIFF=YES C:/Users/J/Temp/processing_pbyYnP/8776553e3d4e41959afaca21f76cc557/outputRaster.tif

Traceback (most recent call last):
File "C:\Users/J/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\site-packages\typeguard\__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "C:\Users/J/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\algorithm\convolutionfilteralgorithmbase.py", line 125, in processAlgorithm
array = rasterReader.arrayFromBlock(block, overlap=overlap)
File "C:\Users/J/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\site-packages\typeguard\__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "C:\Users/J/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\rasterreader.py", line 149, in arrayFromBlock
return self.arrayFromBoundingBoxAndSize(
File "C:\Users/J/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\site-packages\typeguard\__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "C:\Users/J/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\rasterreader.py", line 160, in arrayFromBoundingBoxAndSize
xres = boundingBox.width() / width
ZeroDivisionError: float division by zero

Execution failed after 15.76 seconds

Loading resulting layers

Algorithm 'Spatial convolution Gaussian filter' finished

Comments (8)

  1. Andreas Rabe

    I can’t reproduce this.

    Please send me your raster, maybe the problem is related to the raster itself.

  2. Former user Account Deleted reporter

    Hi Andreas, you’re right. I’ve done more testing and it’s a problem with all rasters I’ve produced in the last few days, older rasters are still working. But they’re from multiple data sources and processed using the same custom QGIS models, so I don’t know why now the change. I’ll send you a working and non-working equivalent, by email?

  3. Andreas Rabe

    Clipping the extent is not a good workaround, would be better to fix this.

    Please share a file that can reproduce the error.

  4. Log in to comment