HRA: AttributeError: 'float' object has no attribute 'lower'

What is the issue or question you have?

i have problems running the Habitat risk assessment model, the logfile says The maximum pairwise risk score for multiplicative risk is 9.0
or The maximum pairwise risk score for euclidean risk is 2.8…

What do you expect to happen?

i don’t understand what is the issue here, i would expect it to run without problems

What have you tried so far?

i’ve tried using invest 3.13
i’ve tried using only 9 stressors
i’ve tried changing the parameters from decay and equation and number of overlapping stressors
i’ve tried using only a couple of habitat and stressors
i’ve checked if all my stressors .tiff are int (instead of float)
ex_criteria_mon.csv (21.4 KB)

i’ve erased all field in my habitat .shp that are float
i’ve checked both the stressors table and the criteria table

Attach the logfile here:

InVEST-natcap.invest.hra-log-2023-05-10–16_48_19.txt (1.7 KB)
InVEST-natcap.invest.hra-log-2023-05-10–16_08_46.txt (1.7 KB)
InVEST-natcap.invest.hra-log-2023-05-10–16_09_49.txt (1.8 KB)
InVEST-natcap.invest.hra-log-2023-05-10–16_10_40.txt (1.7 KB)
InVEST-natcap.invest.hra-log-2023-05-10–16_16_56.txt (1.7 KB)
InVEST-natcap.invest.hra-log-2023-05-10–16_29_23.txt (1.7 KB)
habitat_stressor_mon.csv (3.6 KB)

Hi @Gperilla , thanks for sharing your data.

The error appearing in your logs is this,

  File "natcap\invest\", line 164, in prepare_workspace
  File "invest\", line 469, in main
  File "natcap\invest\", line 537, in execute
  File "natcap\invest\", line 2047, in _parse_criteria_table
AttributeError: 'float' object has no attribute 'lower'

I found a small formatting error in your criteria table. Each stressor row is expected to repeat the column headers, “RATING, DQ, WEIGHT, …”

Please try the attached CSV to see what I mean.
ex_criteria_mon_fixed.csv (25.2 KB)


1 Like

thanks @dave, it solves the initial issue, but now im facing this new Error ‘NoneType’ object is not subscriptable,

i think it has something to do with some rasters sizes, however, the model was able to create the aligned tiffs and reprojected shapes
these are the first stressor and the first habitat
aligned_aeropuerto_mon.tif (57.0 KB)
reprojected_sierra (10.2 KB)

InVEST-Habitat-Risk-Assessment-log-2023-05-11–13_38_23.txt (35.8 KB)

This new error is a tough one. It seems the aligned habitat and the aligned stressor that the model is creating are not actually aligned with one another. There is one extra column of pixels in the habitat raster.

aligned habitat
Width	2793
Height	2972

aligned stressor
Width	2792
Height	2972

I’m not sure of the cause of this yet, but we’ll get back to you as soon as we can. I tested this in version 3.13.0.

thank you @dave, i dont know why or how this error is happening, but i was able to work around it by poligonizing all my stressors, the model seems to work fine when using only poligons,
it worked when i didnt have any rasters (.tif) as habitat or stressors

Okay, thanks @Gperilla, good to know. Yes, I expect it would work fine with all polygons or all rasters. I have your data to reproduce the error, and it is likely a bug in the model, so we’ll try to get to the bottom of it anyway.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.