Martin-Jung / LecoS

LecoS QGis Plugin - Contains several analytical functions for land cover analysis
GNU General Public License v3.0
21 stars 19 forks source link

Python error when performing Lanscape Statistics in LecoS (numpy.core._exceptions._ArrayMemoryError) #25

Closed RafP2021 closed 1 year ago

RafP2021 commented 1 year ago

Hi! I recently installed LecoS from the plugin repository on my QGIS 3.22.4 When I try to run any of the available Landscape Statistics on my raster file, I get the following error message:


numpy.core._exceptions._ArrayMemoryError: Unable to allocate 11.9 GiB for an array with shape (128069, 99432) and data type uint8 Traceback (most recent call last): File "C:\Users/humbo/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LecoS\lecos_dlg.py", line 408, in accept classes, array = lcs.f_landcover(rasterPath,nodata) # Get classes and value File "C:\Users/humbo/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LecoS\landscape_statistics.py", line 137, in f_landcover array = band.ReadAsArray() File "C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\GDAL-3.4.1-py3.9-win-amd64.egg\osgeo\gdal.py", line 3653, in ReadAsArray return gdal_array.BandReadAsArray(self, xoff, yoff, File "C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\GDAL-3.4.1-py3.9-win-amd64.egg\osgeo\gdal_array.py", line 422, in BandReadAsArray buf_obj = numpy.empty([buf_ysize, buf_xsize], dtype=typecode) numpy.core._exceptions._ArrayMemoryError: Unable to allocate 11.9 GiB for an array with shape (128069, 99432) and data type uint8 Versione Python: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] Versione di QGIS: 3.22.4-Białowieża Białowieża, ce8e65e9

Do you know what am I doing wrong? I am not trained in python, therefore I cannot catch the meaning of the message. Than you very much!

Martin-Jung commented 1 year ago

Hi, your input raster is too big for your PC (the amonut of memory is not sufficient). This is indicated by "Unable to allocate 11.9 GiB for an array with shape (128069, 99432) and data type uint8". If the problem continues, try and crop your input raster into smaller piece (like 1/5 of the size or so) and try again.

RafP2021 commented 1 year ago

Ok I got it! Thank you very much