HRA model , TypeError: 'NoneType' object is not subscriptable

Hi,I’m trying to run the HRA Model , and get the following error:
AttributeError: ‘NoneType’ object is not subscriptable.

Any help would be much appreciated!
Thanks!

InVEST-Habitat-Risk-Assessment-log-2021-01-04–19_51_04.txt (6.8 KB)

Hi @Giggle,
Thanks for including the log file! There are a couple of warnings above the error message: A geometry of type MULTIPOLYGON is inserted into layer simplified_protect_area of geometry type POLYGON, which is not normally allowed by the GeoPackage specification, but the driver will however do it. To create a conformant GeoPackage, if using ogr2ogr, the -nlt option can be used to override the layer geometry type. This warning will no longer be emitted for this combination of layer and feature geometry type.
You can try checking for accidental multipolygons (in QGIS you can do this with the Geometry Checker tool: Vector -> Geometry Tools -> Check Validity) and correcting them.
Could you share your data so that I can look into the issue further? You can attach it here or email it to me privately: esoth @ stanford.edu

1 Like

Thank you so much for the answers.I will share my date to you.
HRA_lab1.zip (891.5 KB)
Thank you very much for your attention!

So sorry about the delay on this @Giggle ! And thank you for providing your inputs.

In this case, the model is failing because one of your habitat vectors (天然湿地2.shp) has no features in it. If there aren’t any features in the vector, then there’s nothing to rasterize and you’ll end up with some unexpected results anyways. So could you add a feature to the vector and see if that solves the issue?

Let us know how this goes!
James

1 Like

Thank you for your reply! The previous problem has been solved, but when I tried to change the indicators of exposure(E) and consequence(C), a new problem appeared again in the running of the model.Some new indicators have been added to the criteria(exposure_consequence_criteria).

When I run the HRA model ,there is a error about ValueError: The following stressor-habitat pair(s) do not have at least one exposure rating,
[(‘B2’, ‘512’), (‘B2’, ‘522’), (‘B2’, ‘532’), (‘B2’, ‘112’), (‘B2’, ‘122’), (‘B1’, ‘512’), (‘B1’, ‘522’), (‘B1’, ‘532’), (‘B1’, ‘112’), (‘B1’, ‘122’), (‘A2’, ‘512’), (‘A2’, ‘522’), (‘A2’, ‘532’), (‘A2’, ‘112’), (‘A2’, ‘122’)].
i don’t know to run it success. I hope someone can help me solve this problem.
I will share my Model operation data .

exposure_consequence_criteria.csv (5.75 KB)

InVEST-Habitat-Risk-Assessment-log-2021-03-06–11_08_28.txt (5.32 KB)

Hi @Giggle,
Thanks for reporting this. Your table looks correct to me. I couldn’t replicate the error using only the function that reads that table. If you don’t mind sharing the rest of your inputs, I can debug it further!

In general, the error means that you attempted to index an object that doesn’t have that functionality. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:

None[something]

NoneType is the type of the None object which represents a lack of value, for example, list1 = list.sort(list1) : - here, you are setting it to None. None always has no data, so NoneType object is not subscriptable. In order to correct this error this should be list1.sort().

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