SWY error on task calculate curve number (13)

What is the issue or question you have?

Dear community,

I am a Belgian student and I have to test SWY in the region of Bamako in Mali for a project. I met some mistakes while launching InVEST but I can’t overcome this one:

I checked similar topics and it may be an issue with the NoData value being set incorrectly. I have done it before though and I don’t understand what I can change now…

Here is the hydrologic (hydro_29N), LUC (OCS_2019) and biophysical table I need for my case:
invest_swy.zip (382.2 KB)

Thank you for your help !

1 Like

Hi @MargaMagra, and welcome!

Thanks for posting your data layers. Looking at the land cover map, its NoData value is set to “nan”, which is probably causing the error. NoData values should be set to an actual number, such as 9999, or some other numeric value that is not a valid value for your dataset. Try changing the NoData value and see if that helps.

Also, both of the rasters you posted have values of 0 in them. 0 is not valid for the soil group raster. And there is no value for 0 in the biophysical table. Every value in the land cover raster must have an entry in the biophysical table. Both of these points are discussed in the User Guide.

Also, in general, when you get an error, it’s most useful if you post the entire log file (ends in .txt) that the model creates in your Workspace. That often gives us more information to work with.

~ Stacie


Hello Stacie,

Thank you a lot for your answer !
I changed the 0 value in my land cover raster to 6, same for the biophysical table but I still get an error …
Here is the entire txt script.
InVEST-natcap.invest.seasonal_water_yield.seasonal_water_yield-log-2022-12-18–17_47_23.txt (6.5 KB)

Many thanks in advance !

And here is the new land cover raster and biophys table
biophysical_table_good.csv (609 Bytes)
OCS_reclass_2019_H.tif (638.7 KB)

Hi @MargaMagra -

The raster and biophysical table do look like they’re in sync now, that’s good.

But the error is happening because of the other thing I noted: the NoData value in the land cover raster is set to “nan”, not an actual number. Try changing this and see if it helps.

~ Stacie

Hello @swolny ,

I changed the NoData but I don’t really understand what number I should replace it with. I tried to write a valid lucode (7) for the no data and add it to the biophysical table (with 1 for kc and 100 for CN). Which is incorrect but it’s just trying to get invest to work, but then the error was:
InVEST-natcap.invest.seasonal_water_yield.seasonal_water_yield-log-2022-12-20–12_19_53.txt (12.7 KB)
I also tried with -9999999 and 9999 (for the no data) and adapting the values in the table but I get the same error message.
I don’t understand why it tells me that there is a 0 value of the luc raster in the biophysical table, since I changed all the 0 values by another one…

Maybe I’m missing something obvious …

Again, many thanks in advance !

Hi @MargaMagra -

Which GIS are you using? And what method are you using for assigning the NoData value?

You should not need to add your NoData value to the biophysical table. If it’s set correctly, the model will know that it represents background pixels, and will not look for that value in the table.

~ Stacie

Hello @swolny ,

I am currently using Qgis, the function I use is “fill in the cells without data” from qgis and I also tried “fill in the null values (nodata)” from GDAL. These functions allow me to change the nan value by the one of my choice. I did the same thing with the hydrological raster group.

Do you recommend another function to use? I have an arcgis license but it was asked to use open access software for the work.


There’s a QGIS function called “Fill NoData cells”, which might be one of the ones you tried. Here’s its description: “This algorithm resets the NoData values in the input raster to a chosen value, resulting in a raster dataset with no NoData pixels.” This does not change the NoData value, it only assigns NoData pixels to a valid data value. All valid data values must have an entry in the biophysical table. The raster will still have a NoData value, there just won’t be any pixels with that value.

I know this sounds confusing.

One way to explicitly set the NoData value is the tool “Translate (convert format)”. Give the land cover map as the Input layer, and where it says “Assign a specified nodata value to output bands” give a value like 999. You shouldn’t need to change any other parameters, just save it to a new TIFF. When you look at the output raster’s Properties, you should see NoData set to 999. Try this raster in SWY and see if it helps.

~ Stacie

1 Like

Hello @swolny ,

Omg it worked ! I used projection (wrap) from gdal and set 999 as you said.

Thank you a lot !!

1 Like