Water Yield "Kc" error

Hello

Running the water yield model , after 31 minutes it shows me the KeyError: 'Kc'

can anyone help me with that please

Thx

Comments

  • swolnyswolny Member, NatCap Staff
    edited December 2017
    Hi @Mauroe -

    Any time you have a problem with the InVEST models, please post your whole logfile, that makes it a lot easier for us to troubleshoot. Thanks!

    Taking an initial guess, I'd look at your biophysical table and make sure that you have a field named Kc, and that it has floating point values for all land use classes in your LULC raster.

    ~ Stacie
    Post edited by swolny on
  • Hi Staci, thank you very much this is the logfile, I am going to check anyway

    12/28/2017 17:25:57  natcap.invest.utils INFO     Writing log messages to C:\water_yield\InVEST-Hydropower-Water-Yield-log-2017-12-28--17_25_57.txt
    12/28/2017 17:25:57  natcap.invest.ui.model Level 100 Starting model with parameters:
    Arguments for InVEST natcap.invest.hydropower.hydropower_water_yield 3.4.2:
    biophysical_table_uri        C:/water_yield/biophysical_table_full_4.csv
    calculate_valuation          False
    calculate_water_scarcity     False
    depth_to_root_rest_layer_uri C:/water_yield/inputs_cobogzone/profsuel_proj1.tif
    eto_uri                      C:/water_yield/inputs_cobogzone/eto_co_Project.tif
    lulc_uri                     C:/sdr/inputs/lulc_250.tif
    pawc_uri                     C:/water_yield/inputs_cobogzone/pawc_co_Project.tif
    precipitation_uri            C:/water_yield/inputs_cobogzone/precip_co1.tif
    results_suffix               
    seasonality_constant         2
    sub_watersheds_uri           C:/sdr/subwatersheds.shp
    watersheds_uri               C:/water_yield/inputs_cobogzone/watersheds_co.shp
    workspace_dir                C:\water_yield

    12/28/2017 17:25:57  natcap.invest.hydropower.hydropower_water_yield INFO     Starting Water Yield Core Calculations
    12/28/2017 17:26:10  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 38.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmpox0ifm, psz_message
    12/28/2017 17:26:15  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 88.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmpox0ifm, psz_message
    12/28/2017 17:26:15  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 100.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmpox0ifm, psz_message
    12/28/2017 17:26:16  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     align_dataset_list aligning dataset 1 of 5
    12/28/2017 17:26:23  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     align_dataset_list aligning dataset 2 of 5
    12/28/2017 17:26:36  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 38.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmpkb10ms, psz_message
    12/28/2017 17:26:41  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 84.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmpkb10ms, psz_message
    12/28/2017 17:26:43  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 100.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmpkb10ms, psz_message
    12/28/2017 17:26:43  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     align_dataset_list aligning dataset 3 of 5
    12/28/2017 17:26:51  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 63.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmplv4v5i, psz_message
    12/28/2017 17:26:53  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     ReprojectImage 100.0% complete c:\users\mauric~1.ech\appdata\local\temp\tmplv4v5i, psz_message
    12/28/2017 17:26:54  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     align_dataset_list aligning dataset 4 of 5
    12/28/2017 17:27:05  natcap.invest.ui.model ERROR    Exception while executing <function execute at 0x0BF6A570>
    Traceback (most recent call last):
      File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\ui\model.py", line 1504, in _logged_target
      File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\hydropower\hydropower_water_yield.py", line 139, in execute
    KeyError: 'Kc'
    12/28/2017 17:27:05  natcap.invest.ui.model INFO     Execution finished
    12/28/2017 17:27:05  natcap.invest.utils INFO     Elapsed time: 1m 8.21s

  • MauroeMauroe Member
    Hi
    Happy new year

    I am still trying to run the water yield model Hydropower and I have this error

    01/01/2018 10:18:05  natcap.invest.utils INFO     Writing log messages to C:\water_yield\InVEST-Hydropower-Water-Yield-log-2018-01-01--10_18_05.txt
    01/01/2018 10:18:05  natcap.invest.ui.model Level 100 Starting model with parameters:
    Arguments for InVEST natcap.invest.hydropower.hydropower_water_yield 3.4.2:
    biophysical_table_uri        C:/water_yield/biophysical_table_wyield_co.csv
    calculate_valuation          False
    calculate_water_scarcity     False
    depth_to_root_rest_layer_uri C:/water_yield/inputs_cobogzone/profsuel_proj1.tif
    eto_uri                      C:/water_yield/inputs_cobogzone/eto_co_Project.tif
    lulc_uri                     C:/water_yield/inputs_cobogzone/lulc_250.tif
    pawc_uri                     C:/water_yield/inputs_cobogzone/pawc_co_Project.tif
    precipitation_uri            C:/water_yield/inputs_cobogzone/precip_co1.tif
    results_suffix              
    seasonality_constant         2
    sub_watersheds_uri           C:/sdr/subwatersheds.shp
    watersheds_uri               C:/water_yield/inputs_cobogzone/watersheds_co.shp
    workspace_dir                C:\water_yield

    01/01/2018 10:18:05  natcap.invest.hydropower.hydropower_water_yield INFO     Starting Water Yield Core Calculations
    01/01/2018 10:18:12  natcap.invest.pygeoprocessing_0_3_3.geoprocessing INFO     align_dataset_list aligning dataset 3 of 5
    01/01/2018 10:18:19  natcap.invest.ui.model ERROR    Exception while executing <function execute at 0x0BF2B570>
    Traceback (most recent call last):
      File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\ui\model.py", line 1504, in _logged_target
      File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\hydropower\hydropower_water_yield.py", line 139, in execute
    KeyError: 'Kc'
    01/01/2018 10:18:19  natcap.invest.ui.model INFO     Execution finished
    01/01/2018 10:18:19  natcap.invest.utils INFO     Elapsed time: 13.43s

  • RichRich Administrator, NatCap Staff
    Ugh I'd like to patch this too. Can you also dropbox me this datastack to richsharp@stanford.edu?  Otherwise the problem is that your biophysical table is either missing the column "Kc" or there's an issue with your CSV table. Either way I'm happy to take a look at your data directly.
  • MauroeMauroe Member
    Thank you very much Rich , I still have the problem , I ahve a column Kc but theres a problem with th the table format.
    I'm going to send the data , you need only the table right??

    Thx

    Mauricio
  • HELLO,

    first of all thank you for your time, I would like to bring your attention to this error:

    Run KeyError: 'Kc'

    can u help me to fix this problem?? really hope yes!

    I am attaching the report (log) and the txt of the biophysical table

    thx a lot another time.


  • swolnyswolny Member, NatCap Staff
    Hi @FRASELVINI -

    I don't think that the model is case-sensitive, so it shouldn't matter that you're using "kc" instead of "Kc" (although you could try changing that as a test.) It does look like there is a blank line at the end of the table, which sometimes causes odd errors. Can you try deleting that blank line at the end and see if it helps? Otherwise, I don't see an obvious problem with the table.

    ~ Stacie
  • RichRich Administrator, NatCap Staff
    Hi @FRASELVINI, just in case this issue didn't resolve for you, I believe we've provided better support for semicolon separated CSV tables that might have affected your issue back in the day. That support is actively in InVEST 3.5.0 that you can download here: https://naturalcapitalproject.stanford.edu/invest/
Sign In or Register to comment.