This forum is shutting down! Please post new discussions at community.naturalcapitalproject.org

index out of bounds

Hi,

I am running the seasonal water yield model and am getting the error "IndexError: index 17 is out of bounds for axis 1 with size 17" when the model is calculating curve numbers. This seems to me like an error with my input biophysical table, but I have used the table before without an error. I've attached the log here. 

Does anyone have any ideas what this error is referring to?

Thanks!

Keri

Comments

  • RichRich Administrator, NatCap Staff
    Hi Keri, is it possible you have a landcover value in your raster that doesn't have a corresponding entry in the curve number table?  Offhand that's what the error looks like on the source side...
  • Hi Rich,

    Thanks!

    That was my guess about this error before I posted, but I cant find any problems in matching up the raster values to the curve number table. In fact, the 17th(last) row has a value of 95 (I am guessing that is what "index17") is referring to, and there are thousands of pixels with that value in my raster.

    There is a possible problem the other way around: I had a "no data" row in the curve number table, but did not have "no data" pixels in my land cover map. I deleted the no data row, and just got the same error again, but for index 16. 

    Other than looking at the raster attribute table and checking it against the table, I am not sure how to troubleshoot this. Do you have any suggestions?

    Thanks!

    Keri
  • RichRich Administrator, NatCap Staff
    Hi Keri, I can take a look if you like.  Can you dropbox me your datastack to richsharp@stanford.edu?
  • I’m running the seasonal
    water yield model in InVEST 3.3.1 and getting the same error. I’ve successfully gotten the model to run with
    one land cover layer, and am trying a different one, but get the following
    error.

    Browsing the forum seems
    to suggest that this error is caused by either 1) a misprojected layer or 2) a
    lack of alignment between values in the land cover layer and the biophysical
    table.

    http://forums.naturalcapitalproject.org/index.php?p=/discussion/1049/coastal-vulnerability-error/p1

    (this thread)

     

    However, all the data
    use the same spatial reference system as the other layers that run fine, and
    all the values in the biophysical table match those of the raster dataset.

     

    image

     

    The log file is below.
    Thanks for any help you can offer!


    Arguments:

    aoi_path                    C:/Data/Rwanda/invest_seasonal_water/inputs/rwanda_watershed.shp

    beta_i                      1.0

    biophysical_table_path      C:/Data/Rwanda/invest_seasonal_water/data_comparison/inputs/biophysical_table_globeland3.csv

    climate_zone_raster_path    C:/Data/Rwanda/invest_seasonal_water/inputs/ecoregions.tif

    climate_zone_table_path     C:/Data/Rwanda/invest_seasonal_water/inputs/climate_zone_events_final.csv

    dem_raster_path             C:/Data/Rwanda/invest_sediment/Inputs/dem_300m_filled.tif

    et0_dir                     C:\Data\Rwanda\invest_seasonal_water\inputs\et

    gamma                       1.0

    l_path                      

    lulc_raster_path            C:/Data/Rwanda/invest_seasonal_water/data_comparison/inputs/lulc_globeland_2010_300m.tif

    monthly_alpha               True

    monthly_alpha_path          C:/Data/Rwanda/invest_seasonal_water/inputs/monthly_alpha.csv

    precip_dir                  C:\Data\Rwanda\invest_seasonal_water\inputs\precip

    rain_events_table_path      

    soil_group_path             C:/Data/Rwanda/invest_seasonal_water/inputs/HSG_Rwanda_Burundi.tif

    threshold_flow_accumulation 1000

    user_defined_climate_zones  True

    user_defined_local_recharge False

    workspace_dir               C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300



    01/19/2017 16:42:26  root               INFO     Logging will be saved to natcap.invest.seasonal_water_yield.seasonal_water_yield-log-2017-01-19--16_42_26.txt

    01/19/2017 16:42:26  root               DEBUG    Loaded the model from natcap.invest.seasonal_water_yield.seasonal_water_yield

    01/19/2017 16:42:26  root               INFO     Executing the loaded model

    01/19/2017 16:42:26  root               INFO     Running InVEST version "3.3.1"

    01/19/2017 16:42:26  root               INFO     Python architecture: ('32bit', 'WindowsPE')

    01/19/2017 16:42:26  root               INFO     Disk space remaining for workspace: 268.11 GB

    01/19/2017 16:42:26  root               INFO     Pointing temporary directory at the workspace at C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300

    01/19/2017 16:42:26  root               INFO     Updating os.environ["TMP"]=C:\Users\kbagstad\AppData\Local\Temp to C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300

    01/19/2017 16:42:26  root               INFO     Updating os.environ["TEMP"]=C:\Users\kbagstad\AppData\Local\Temp to C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300

    01/19/2017 16:42:26  root               INFO     Setting os.environ["TMPDIR"]=C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300

    01/19/2017 16:42:26  root               INFO     Setting tempfile.tempdir to C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300\tmp

    01/19/2017 16:42:26  root               INFO     Starting natcap.invest.seasonal_water_yield.seasonal_water_yield

    01/19/2017 16:42:26  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     prepare and test inputs for common errors

    01/19/2017 16:42:26  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     Building file registry

    01/19/2017 16:42:27  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     Checking that the AOI is not the output aggregate vector

    01/19/2017 16:42:27  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     Aligning and clipping dataset list

    01/19/2017 16:42:32  pygeoprocessing.geoprocessing INFO     align_dataset_list aligning dataset 6 of 28

    01/19/2017 16:42:37  pygeoprocessing.geoprocessing INFO     align_dataset_list aligning dataset 13 of 28

    01/19/2017 16:42:43  pygeoprocessing.geoprocessing INFO     align_dataset_list aligning dataset 22 of 28

    01/19/2017 16:42:46  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     Masking invalid lulc, dem, and possible soil group overlap

    01/19/2017 16:42:46  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     flow direction

    01/19/2017 16:42:48  pygeoprocessing.routing.routing_core INFO     labeling flats

    01/19/2017 16:42:48  pygeoprocessing.routing.routing_core INFO     draining away from higher

    01/19/2017 16:42:48  pygeoprocessing.routing.routing_core INFO     draining towards lower

    01/19/2017 16:42:48  pygeoprocessing.routing DEBUG    flats exist, calculating flow direction for them

    01/19/2017 16:42:49  pygeoprocessing.routing.routing_core INFO     labeling flats

    01/19/2017 16:42:49  pygeoprocessing.routing.routing_core INFO     draining away from higher

    01/19/2017 16:42:49  pygeoprocessing.routing.routing_core INFO     draining towards lower

    01/19/2017 16:42:49  pygeoprocessing.routing INFO     flats exist on second pass, must be flat areas that abut the raster edge

    01/19/2017 16:42:49  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     flow weights

    01/19/2017 16:42:49  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     flow accumulation

    01/19/2017 16:42:49  pygeoprocessing.routing DEBUG    starting flow accumulation

    01/19/2017 16:42:50  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     stream thresholding

    01/19/2017 16:42:50  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     quick flow

    01/19/2017 16:42:50  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     loading number of monthly events

    01/19/2017 16:42:51  natcap.invest.seasonal_water_yield.seasonal_water_yield INFO     calculate curve number

    01/19/2017 16:42:51  root               ERROR    ---------------------------------------------------

    01/19/2017 16:42:51  root               ERROR    ---------------------- ERROR ----------------------

    01/19/2017 16:42:51  root               ERROR    ---------------------------------------------------

    01/19/2017 16:42:51  root               ERROR    Error: exception found while running natcap.invest.seasonal_water_yield.seasonal_water_yield

    01/19/2017 16:42:51  root               DEBUG    

    01/19/2017 16:42:51  root               DEBUG    Build details

    01/19/2017 16:42:51  root               DEBUG    Interpreter

    01/19/2017 16:42:51  root               DEBUG    Current temp dir: C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300\tmp

    01/19/2017 16:42:51  root               DEBUG    tempfile.tempdir: C:\Data\Rwanda\invest_seasonal_water\data_comparison\globeland_2010_300\tmp

    01/19/2017 16:42:51  root               DEBUG    

    01/19/2017 16:42:51  root               DEBUG    System

    01/19/2017 16:42:51  root               DEBUG    OS              : Windows-7-6.1.7601-SP1

    01/19/2017 16:42:51  root               DEBUG    Processor architecture: AMD64

    01/19/2017 16:42:51  root               DEBUG    FS encoding     : mbcs

    01/19/2017 16:42:51  root               DEBUG    Preferred encoding: cp1252

    01/19/2017 16:42:51  root               DEBUG    

    01/19/2017 16:42:51  root               DEBUG    Python

    01/19/2017 16:42:51  root               DEBUG    Version         : 2.7.9

    01/19/2017 16:42:51  root               DEBUG    Build           : ('default', 'Dec 10 2014 12:24:55')

    01/19/2017 16:42:51  root               DEBUG    Compiler        : MSC v.1500 32 bit (Intel)

    01/19/2017 16:42:51  root               DEBUG    Implementation  : CPython

    01/19/2017 16:42:51  root               DEBUG    Architecture    : 32bit

    01/19/2017 16:42:51  root               DEBUG    Linkage format  : WindowsPE

    01/19/2017 16:42:51  root               DEBUG    

    01/19/2017 16:42:51  root               DEBUG    Packages

    01/19/2017 16:42:51  root               DEBUG    Cython          : ?

    01/19/2017 16:42:51  root               DEBUG    Numpy           : 1.11.0

    01/19/2017 16:42:51  root               DEBUG    Scipy           : 0.16.0b2

    01/19/2017 16:42:51  root               DEBUG    OSGEO           : 1.11.3

    01/19/2017 16:42:51  root               DEBUG    Shapely         : 1.5.5

    01/19/2017 16:42:51  root               DEBUG    InVEST          : 3.3.1

    01/19/2017 16:42:51  root               DEBUG    

    01/19/2017 16:42:51  root               DEBUG    

    01/19/2017 16:42:51  root               DEBUG    Exception not environment-related

    01/19/2017 16:42:51  root               DEBUG    Printing traceback

    Traceback (most recent call last):

      File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.iui.executor", line 560, in runModel

      File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.seasonal_water_yield.seasonal_water_yield", line 163, in execute

      File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.seasonal_water_yield.seasonal_water_yield", line 371, in _execute

      File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.seasonal_water_yield.seasonal_water_yield", line 707, in _calculate_curve_number_raster

      File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\pygeoprocessing.geoprocessing", line 2412, in vectorize_datasets

      File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.seasonal_water_yield.seasonal_water_yield", line 697, in cn_op

    IndexError: index 8 is out of bounds for axis 1 with size 8



    01/19/2017 16:42:51  root               ERROR    Exiting due to failures

    01/19/2017 16:42:51  root               INFO     Elapsed time: 24.85s

  • I was getting this error as a result of my "nodata" pixels. Setting the nodata value to 255 and having a 255 value in the biophysical table resolved the issue.  

    I think the problem was coming up because the nodata value in my rasters was "-128" by default, but "-128" is also 255 in an unsigned byte.

    Hope this helps!
  • RichRich Administrator, NatCap Staff
    Yikes, replied to the wrong thread here.  And that unsigned byte issue is an annoying one for us.  Did Keri's solution work for you Ken?
  • Thanks for the suggestion Keri! I exported my old raster with a nodata value of -128 to instead use nodata a value of 128, and added a dummy row to my biophysical table with the value 128, and it worked fine.

    Interestingly enough I'd previously tried adding a row to the nodata table for -128, but still got errors then. For future reference, are there certain models for which you need to enter a row in the biophysical tables for nodata values, and do those values always have to be positive? Thanks!
Sign In or Register to comment.