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

Error in float() argument #24

Closed Floreanita closed 1 year ago

Floreanita commented 1 year ago

Hello everyone, I am using the plug-in LecoS (version 3.0.1.) on QGis (3.22.14) trying to perform a landscape proportion metrics within the Overlay Raster Metrics (Polygons) function. Unfortunately, the process have failed returning this error:

Traceback (most recent call last): File "C:\Users/anita/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LecoS\lecos_sextantealgorithms.py", line 865, in processAlgorithm r.append(float(item[feature][2])) TypeError: float() argument must be a string or a number, not 'NoneType'

Execution failed after 65.88 secondi (1 minuto 6 secondi)

My input parameters are:

{ 'ADDTABLE' : False, 'CMETRIC' : 1, 'IS_CLASS' : True, 'LAND_GRID' : 'C:/Users/anita/Documents/LAVORO/UNIFI_Materiali/GIS_Progetti/Progetto_Lecos/Toscana_raster_3035_nodata.tif', 'LC_CLASS' : 1, 'LMETRIC' : 0, 'OUTPUT_FILE' : 'TEMPORARY_OUTPUT', 'VECTOR_GRID' : 'C:/Users/anita/Documents/LAVORO/UNIFI_Materiali/GIS_Progetti/Progetto_Lecos/2017_SP_Buffer100m.shp' }

I don't understand what the problem is, anyone could help me?

Thank you in adavance!

Floreanita commented 1 year ago

Just to add some information: Yesterday I tried to perform some landscape metrics with Lecos to explore the Plugin for the first time. Everything went well, so I have saved my Qgis project to continue the analysis later. Today I haven't been able to perform any analysis due to the above mentioned error. So I have tried to create my raster and vector objects (from the beginning) again, disinstall and install the plugin but it still doesn't work. What could be the problem? Thank you all in advance!

Martin-Jung commented 1 year ago

These issues are usually when temporary layers are not saved somewhere. The LecoS plugin requires a fixed data source of any vector or raster layer somewhere. Many QGIS functionalities these days however create temporary layers, sometimes in memory. Try and save each layer somewhere and then rerun it again.

Floreanita commented 1 year ago

Hi @Martin-Jung! Thank you for replying. :) Actually, I have checked if my layers input were saved on my hardware before start working, but I will verify again because something could be went wrong (i'm not a Qgis expert). Curiously, I have "discovered" that using the option "add to attribute table" the error was generated but, at the same time, the vector's attribute table contain the results for the "landscape proportion metrics". So i guess I can still work. Thank you so much for helping me!

Floreanita commented 1 year ago

Update: [Overlay Raster Metrics (Polygons)] The error "TypeError: float() argument must be a string or a number, not 'NoneType'" still remain but I can still calculate the landscape proportion metric since the results were added to the attribute table. Moreover, it seems that only small-extent buffer elicit this type of error, since when the buffer radius is >= 500m the error disappear and the output layer is generated.

However, I have another doubt: In the Overlay Raster Metrics (Polygons) interface there is the possibility to calculate class and landscape metrics at the same time (attached picture). To run the analysis I am obligate to chose both option but I have never obtain the landscape-level metrics output. How could I do to calculate a landscape-level metric (for instance, Simpson Diversity Index) in a buffer? Maybe I am doing something wrong but I am not understanding what.... Thank you all in advance for helping me!

Capture