Type Error-Annual Water Yield

Hello team,
I encountered this error. Kindly help out

10/09/2023 11:22:55 pygeoprocessing.geoprocessing INFO all done processing polygon sets for watershed_results_wyield_results.shp
10/09/2023 11:22:55 taskgraph.Task ERROR Something went wrong when adding task create_ws_id_vector_output (15), terminating taskgraph.
Traceback (most recent call last):
File “taskgraph/Task.py”, line 674, in add_task
File “taskgraph/Task.py”, line 1093, in _call
File “natcap/invest/annual_water_yield.py”, line 935, in write_output_vector_attributes
File “natcap/invest/annual_water_yield.py”, line 1192, in compute_watershed_valuation
TypeError: can’t multiply sequence by non-int of type ‘str’
10/09/2023 11:22:55 natcap.invest.utils ERROR Exception while executing natcap.invest.annual_water_yield
Traceback (most recent call last):
File “natcap/invest/utils.py”, line 164, in prepare_workspace
File “invest/cli.py”, line 469, in main
File “natcap/invest/annual_water_yield.py”, line 843, in execute
File “taskgraph/Task.py”, line 674, in add_task
File “taskgraph/Task.py”, line 1093, in _call
File “natcap/invest/annual_water_yield.py”, line 935, in write_output_vector_attributes
File “natcap/invest/annual_water_yield.py”, line 1192, in compute_watershed_valuation
TypeError: can’t multiply sequence by non-int of type ‘str’
10/09/2023 11:22:55 natcap.invest.utils INFO Elapsed time: 2.07s
10/09/2023 11:22:55 natcap.invest.utils INFO Execution finished

1 Like

Hi, I got a solution to this Error.
Thanks

Glad to hear that you got a solution, @Safari1. It would be great if you’d let us know what the solution is, so that others on the forum can benefit from it.

~ Stacie

Hi Stacie,
To prove where the strings were coming from, I dragged my Hydro power valuation table into QGIS and checked in the “Fields” under “Information”. I realised that all my fields were reading as strings even if they were real numbers in my csv file. I was using UTF-8 Comma delimited and non of them were strings. I therefore opened the attribute table in qgis and created a prototype of the fields, this time choosing real numbers or integers. I deleted all former fields showing strings and saved.
I encountered the same challenge with the Water demand table and that’s exactly how i solved it.

2 Likes

Yep, that makes sense … thanks @Safari1 ! I confirm that the AWY model uses the field values directly, so the data type of the columns matters. In this case, they need to be real numbers or integers.

Having said that, InVEST 3.14.0 and later should do this numerical typecasting for you. @Safari1 what version of InVEST are you using?

I use 3.13.0
Since 3.14.0 is out I will update and try out.

1 Like

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