This forum is shutting down! Please post new discussions at

SWY - 'KeyError' on Soil Group ?

Each time I try to run my SWY model, it stops quickly with the following error : "KeyError
encountered :
At this point, some rasters have been correctly produced (dem_aligned, flow_dir, stream...). But when I open "soil_group_aligned" raster on my GIS software, the default minimum value is precisely -3.4e+38.
So I guess both issues could be linked : my soil group raster does include some NA (see attached). Has anybody faced the same issue ? How to solve it ?
Thanks a lot !
416 x 364 - 5K


  • swolnyswolny Member, NatCap Staff
    Hi @Emmanuel_Faure -

    Which version of InVEST are you using? In general, that error is caused by there being a value in one of your raster layers (usually land use/land cover) that does not have a matching value in the biophysical table. For soil groups, the model combines the soil group raster with the land use/land cover map, and maps the result to CN_A/CN_B/etc in the biophysical table. Take a look at those inputs and see if there's anything funny going on with the values, make sure that you have a NoData value set properly, and make sure that you've got all lucodes in the LULC raster included in the biophysical table.

    And please post your whole log file, it will give us more information to go on. Thanks!

    ~ Stacie
  • edited May 2018
    Hi @swolny,
    Thank you ! Here is my log. I am using the 3.4.2 version of InVEST.

    Fine by me, I'll check what you said and get back to you as soon as possible. By the way, my soil group raster is filled with numeric values (2/3/4), rather than letters : is it OK for InVEST to make it match with soil groups B/C/D ?
    Post edited by Emmanuel_Faure on
  • Hello @swolny. So,
    -I have replaced all NA in soil_group raster with plausible values;
    -I have checked everything you said;
    And still the same error is being displayed. Is there any other explanation ?

    Here is my new log.

  • DougDoug Administrator, NatCap Staff
    Hi @Emmanuel_Faure 

    Just an active InVEST user here, but thought maybe I could help,

    It looks like the error might be due to a nodata issue in the soil group raster. The specific value it is struggling with is:

    KeyError: -3.4e+38
    Sometimes these really large nodata values can be problematic when checking for nodata due 
    to precision issues. Could you check to see if the raster nodata value is this large negative value, 
    and if so, could you try setting the nodata value to say, -9999, that should be a safe nodata value.

    And yep, I believe that soil group raster should be values 1 to 4, and it'll map to the correct a,b,c,d types. 
Sign In or Register to comment.