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

**URL:** <https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064>\
**Category:** Software Support\
**Tags:** seasonal-water-yield\
**Created:** [June 25, 2025, 9:36pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064 "2025-06-25T21:36:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 25, 2025, 9:36pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/1 "2025-06-25T21:36:50Z")

</div>

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**.

#### 🔍 **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.

#### ⚠ **Error Message** :

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

makefile

CopyEdit

```auto
KeyError: 2.0

```

That is:

makefile

CopyEdit

```auto
KeyError: 2.0

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

```

#### 🧠 **What I have tried so far** :

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

And still the issue persists.

* * *

#### 🎯 **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!

---

<div class="post-metadata">

**Author:** ![swolny](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/swolny/32/181_2.png) [@swolny](https://community.naturalcapitalalliance.org/u/swolny)\
**Post date:** [June 25, 2025, 11:12pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/2 "2025-06-25T23:12:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 26, 2025, 5:50am UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/3 "2025-06-26T05:50:53Z")

</div>

[InVEST-seasonal\_water\_yield-log-2025-06-26–00\_41\_01.txt](https://community.naturalcapitalalliance.org/uploads/short-url/s4LblK7e2JRM64FDnXm89AtVWnQ.txt) (53.5 KB)

@swolny

---

<div class="post-metadata">

**Author:** ![swolny](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/swolny/32/181_2.png) [@swolny](https://community.naturalcapitalalliance.org/u/swolny)\
**Post date:** [June 26, 2025, 1:04pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/4 "2025-06-26T13:04:38Z")

</div>

Thanks for the logfile @abir. It does not contain a KeyError, but does show errors related to file access. These might be caused by one of the input files being open in another program (like an editor, or backup app). Or perhaps the input files and/or Workspace is on a network drive? Sometimes that can cause problems.

~ Stacie

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 26, 2025, 6:41pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/5 "2025-06-26T18:41:14Z")

</div>

sorry i uploaded the wrong txt file..

[InVEST-seasonal\_water\_yield-log-2025-06-26–23\_25\_33.txt](https://community.naturalcapitalalliance.org/uploads/short-url/our1GBvvarlZAak3o0w3DOB3Yy6.txt) (32.2 KB)

 ![Screenshot (119)](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/c/c03fe2d04779284b9eab16cac38f46965ff6affa.png)  
[lulc\_2022\_resampled.zip](https://community.naturalcapitalalliance.org/uploads/short-url/l4gJfpTuufBmGKlJ0k2xMIYw5SC.zip) (456.0 KB)  
[bio\_physical.csv](https://community.naturalcapitalalliance.org/uploads/short-url/zjA6gueRcUq8aobWDXVA7IV74yO.csv) (1.1 KB)

I have uploaded all the required files, including the TXT file for the LULC biophysical table. Could you please help me check and resolve the error I’m facing? Thank you in advance for your support!

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [June 26, 2025, 7:12pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/6 "2025-06-26T19:12:10Z")

</div>

Hi @abir,

Based on this log file and what’s happening in the code at this point, I think the issue may actually be with your Rain Events Table CSV, not with your LULC classes or biophysical table. It looks like the model can’t find a row in the Rain Events Table CSV for month 2. Can you double check your table? Per the User’s Guide, this table should have columns named **month** and **events** , where **month** values “are the numbers 1-12 corresponding to each month, January (1) through December (12).” Feel free to also upload that CSV if you’d like another set of eyes on it!

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 27, 2025, 9:12am UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/7 "2025-06-27T09:12:56Z")

</div>

![image](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/0/09c8d013123bb1b8ef2b0764536a4e010d79bf0e.jpeg)  
now I’m having problem as you can see in this picture why the map of base flow is not aligned with shapefile where quick flow is aligned and why this kind of values?

what is the problem.

please resolve it  
thank You

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [June 27, 2025, 2:39pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/8 "2025-06-27T14:39:23Z")

</div>

Hi @abir,

It’s difficult to say what may be going on just based on a screenshot. If you can share a link to your input data, I’d be happy to run the model and take a look at the results.

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 27, 2025, 9:11pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/9 "2025-06-27T21:11:47Z")

</div>

Thank you for the support. I reviewed the logs and found that the error occurred due to misaligned spatial references among the input rasters.

I realized that some of the inputs were in geographic coordinates (EPSG:4326) while others were in projected UTM (meters). I’ve now reprojected all rasters to a common projected CRS (EPSG:32644), ensuring they overlap spatially.

Additionally, for model parameters:

- I’m using a **threshold flow accumulation value of 1000** to define streams. This seemed appropriate for my basin size (~143,219 km²), but I’m open to suggestions if a more suitable value is recommended.
- The **alpha** parameter is set to **1/12** , and **beta** and **gamma** are both set to **1** , as per the default configuration.

Please let me know if you have any recommendations for tuning these values or further optimizing model performance. Thanks again!

link- [https://drive.google.com/drive/folders/1JlwiKuDCo1\_O53y5BbN2RA4ryc2zlGBt?usp=drive\_link](https://drive.google.com/drive/folders/1JlwiKuDCo1_O53y5BbN2RA4ryc2zlGBt?usp=drive_link)

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 28, 2025, 7:51am UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/10 "2025-06-28T07:51:47Z")

</div>

@megannissel please check it.

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [June 30, 2025, 1:34pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/11 "2025-06-30T13:34:18Z")

</div>

Hi @abir,

I’ve requested access to the folder you sent. I’m still happy to run the model to validate that your inputs are producing error-free outputs, but it sounds like you’ve already solved your problems with misalignment! Unfortunately I’m not an expert in this model’s science, so I don’t have any insight in terms of value-tuning; I’d recommend going with whatever values make sense based upon your research.

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 30, 2025, 2:02pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/12 "2025-06-30T14:02:50Z")

</div>

Hello @megannissel

i have solved my issue right now i am in trouble to interpret my result of base flow and if you see in the bottom left corner their is a gap in the map

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/a/a2edca9105b34a91c4c7d5961793b739b7d9ca16.jpeg)

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [June 30, 2025, 2:37pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/13 "2025-06-30T14:37:49Z")

</div>

Hi @abir,

I do see the gap in the map. If you either make that Drive folder public or share it with me (mnissel@stanford.edu), I can take a look at your inputs to see if I can help you figure out where that gap is coming from.

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [June 30, 2025, 4:56pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/14 "2025-06-30T16:56:53Z")

</div>

Hello @megannissel

sorry for being late.

new link - [https://drive.google.com/file/d/1OWYeZVJRsqaZ4lEjizazyUZlqkekadpM/view?usp=sharing](https://drive.google.com/file/d/1OWYeZVJRsqaZ4lEjizazyUZlqkekadpM/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [June 30, 2025, 7:38pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/15 "2025-06-30T19:38:00Z")

</div>

Hi @abir,

I was able to run the model using your data and I’m also seeing that gap in the output rasters. It looks like it’s likely a result of a NoData section in your ET0 rasters that overlaps with your AOI, as you can see in this screenshot:

 ![Screenshot 2025-06-30 at 3.23.26 PM](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/0/0decc142cf02015762a38d50e68a06cc1b7e3c6a.png)

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [July 1, 2025, 5:23am UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/16 "2025-07-01T05:23:30Z")

</div>

@megannissel  
thanks for the update. Do you have any solution ?

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/a/adc3267fb7688d20372fa2105dc6b5a77e1a05e2.jpeg)

Another technical sought why this base flow values are to high ?  
how to fix it ?

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [July 1, 2025, 2:33pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/17 "2025-07-01T14:33:57Z")

</div>

Hi @abir,

The model won’t be able to calculate results in places where there’s missing input data to use in those calculations. In order to get results covering your entire AOI, you would therefore need to provide ET0 rasters that include values for all of the pixels overlapping your AOI. If ET0 data for the currently-missing area doesn’t exist, or cannot be found, that may represent a limitation in your analysis.

As for the large values you’re seeing in B\_sum.tif, as the User Guide says, this raster represents “the flow through a pixel, **contributed by all upslope pixels** , that is not evapotranspired before it reaches the stream.” So it’s very possible for this to be a large number, if there is a lot of precipitation, and/or a large upslope contributing area, and/or low evapotranspiration. You can see similarly large values in the B\_sum.tif raster produced by running the model against our sample data.

---

<div class="post-metadata">

**Author:** ![abir](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@abir](https://community.naturalcapitalalliance.org/u/abir)\
**Post date:** [July 1, 2025, 2:52pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/18 "2025-07-01T14:52:45Z")

</div>

Hello @megannissel @swolny

I’m happy to inform you that I have successfully resolved all the issues I was facing—many thanks to your team for the support. The model outputs are excellent and align well with my expectations.

However, I noticed that some of the raster outputs contain negative starting values, as shown in the attached image. I would like to understand how to interpret these negative values. Are they indicative of an error, or are they a normal part of the model’s calculation?

Looking forward to your clarification.

Best regards,  
Swarnajit Roy

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/f/f0acd90e1f28474e029fee1c516dedd38a43f8ae.jpeg)

---

<div class="post-metadata">

**Author:** ![megannissel](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/megannissel/32/3547_2.png) [@megannissel](https://community.naturalcapitalalliance.org/u/megannissel)\
**Post date:** [July 2, 2025, 2:00pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/19 "2025-07-02T14:00:10Z")

</div>

Hi @abir,

I’m glad to hear you’ve successfully resolved your issues with alignment!

There are several model results that can indeed be negative. Per the User’s Guide section on [Local Recharge](https://storage.googleapis.com/releases.naturalcapitalproject.org/invest-userguide/latest/en/seasonal_water_yield.html#local-recharge): “Local recharge can be negative if a pixel does not receive enough of its own water to satisfy its vegetation requirements (determined by its crop factor Kc), so it uses water generated upslope of the pixel as well (referred to as an “upslope subsidy”.)” The raster in your screenshot, L\_avail, is the “Map of available local recharge L\_avail.” And L\_avail, according to the documentation accompanying [Equation 97](https://storage.googleapis.com/releases.naturalcapitalproject.org/invest-userguide/latest/en/seasonal_water_yield.html#equation-swy-8), “is the available recharge to a pixel, which is L\_i whenever L\_i is negative, and a proportion γ of L\_i when it is positive.”

So, to summarize, the local recharge of a pixel (L\_i) can be negative and, if it is, L\_avail will also be negative.

It is also worth noting that the values in the L\_avail raster should be interpreted as relative values, not absolute (see [Interpreting Results](https://storage.googleapis.com/releases.naturalcapitalproject.org/invest-userguide/latest/en/seasonal_water_yield.html#interpreting-results) in the User’s Guide).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/8/8d95591aa074da87ea0fdd61ca47c1c3c0588aa7.png) [@system](https://community.naturalcapitalalliance.org/u/system)\
**Post date:** [September 30, 2025, 2:01pm UTC](https://community.naturalcapitalalliance.org/t/problem-statement-seasonal-water-yield-model-keyerror-2-0-despite-proper-lulc-and-biophysical-table-setup/6064/20 "2025-09-30T14:01:01Z")

</div>

Closed on September 30, 2025, 2:01pm UTC

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