Problem Statement: Seasonal Water Yield Model KeyError: 2.0 Despite Proper LULC and Biophysical Table Setup

I’m running the Seasonal Water Yield (SWY) model (InVEST version 3.16.0), and I’m encountering a persistent issue with the LULC classes and biophysical table lookup.

:magnifying_glass_tilted_left: What I did:

  • My LULC raster contains the classes [0, 10, 20, 30, 40, 50, 60, 80, 100, 110, 120, 130, 150, 180, 190, 200, 210].
  • My biophysical table contains corresponding lucode values for all of these classes.
  • I checked the raster pixel types — they are int32.
  • To be extra cautious, I also:
    • Added a dummy 2 class to the biophysical table because I suspected a float/int mismatch issue (KeyError: 2.0).
    • Converted the biophysical table lucode column to float so that the data types align.

:warning: Error Message:

Despite these steps, InVEST throws the same exception every time:

makefile

CopyEdit

KeyError: 2.0

That is:

makefile

CopyEdit

KeyError: 2.0

Traceback:
  ...
  pandas\core\indexes\base.py in get_loc
  ...

:brain: What I have tried so far:

:white_check_mark: Ensured LULC contains no 2s
:white_check_mark: Added dummy lucode=2 to the biophysical CSV
:white_check_mark: Converted biophysical lucode column to float
:white_check_mark: Converted LULC to int32
:white_check_mark: Checked that NoData is properly set in the LULC

And still the issue persists.


:bullseye: Request:

  1. Why does the model look for class 2.0 when it doesn’t exist in my raster or table?
  2. Could this be an internal bug where the model incorrectly infers a 2 class?
  3. Is there a recommended workflow for ensuring datatype compatibility (int vs float) between LULC and the biophysical table?

Your guidance would be greatly appreciated — this issue is blocking my SWY analysis entirely. Thanks in advance!

Hi @abir -

Thanks for all of that information about what you’ve tried. We also ask that you post the entire log file (ends in .txt) that the model creates in your Workspace. Thanks again.

~ Stacie

InVEST-seasonal_water_yield-log-2025-06-26–00_41_01.txt (53.5 KB)

@swolny