This forum is shutting down! Please post new discussions at

Need help with Recreation Model errors

Travis_PTravis_P Member
edited December 2018 in General

Hi folks!

I'm experimenting with the Recreation Model in preparation for a study to assess ecosystem service benefits associated with management and restoration of coastal ecosystems in Puget Sound, WA.  In the study we will have several different land/habitat change scenarios to use as predictors.  For now I'm using only two predictors as a means of learning the model: The predictors are habitat types within the Nisqually National Wildlife Refuge in 1980 & 2015.  I've tried with a third predictor consisting of observation platforms located within the Nisqually NWR with the same results.

 After running the model once with a single predictor (1), and once with both predictors (2), I get error messages such as "IndexError: list index out of range" and "IndexError: u'point'".

Even with the errors, a result is still produced.  But the result is identical to running the model without predictors.  In otherwords, my "regression_coefficients.shp" attribute table looks like the "pud_results.shp" and there was no "regression_coefficients.txt." produced.  I’m assuming that this is as a result of the errors?  Or perhaps I'm using too few predictors, or maybe it is simply user error on my part.

 I've attached the logs for each run (1 & 2), as well as a jpeg of my CSV table (I was unable to attach the CSV to this message).

 I would greatly appreciate any help and additional tidbits of info as I'm trying to wrap my head around this model.



Post edited by Travis_P on


  • DaveDave Member, Administrator, NatCap Staff
    Hi @Travis_P, thanks for posting.

    A couple things jump out looking at those CSV files. First, in the "type" column, the entry must match exactly one of the options detailed in the User's Guide section for the "Predictor Table". So for a raster predictor, you have either:

    • raster_mean: Predictor is a raster. Metric is the mean of the non-nodata values of the raster that intersect the AOI grid cell or polygon.
    • raster_sum: Predictor is a raster. Metric is the sum of the non-nodata values of the raster that intersect the AOI grid cell or polygon.
    Unfortunately these were designed with continuous numeric data in mind, whereas in your case you probably have categorical landcover data. So neither option is a good choice for your habitat types rasters. A workaround would be to convert the raster to a vector, and then save a single shapefile for each habitat type of interest (e.g. wetlands.shp, forest.shp, pasture.shp, etc.). Then each of those files could be individual predictors, and you would choose from the polygon options for the "type" value.  

    So, incorrect values in that "type" column explain the IndexErrors you have seen. After that is sorted out, you should see additional columns in "regression_coefficients.shp" - one for each predictor - and the regression_coefficients.txt with the regression results.

    As far as the design of your analysis, I think you've got a great idea in mind to build a regression with different habitat types as predictors, as well as things like visitor infrastructure. Such a regression would tell you how each predictor is positively/negatively correlated with visitation (the PUD map). Since photos come from 2005 - 2017, you'll probably want to build that regression using your 2015 habitat data (and you could consider limiting the date range of the photos, if photos are abundant). After that, you could consider using the 1980 data in a "Scenario Predictor Table", which would predict visitation patterns given that landscape of the past. It doesn't make sense to use data from both time periods as predictors in the same regression. 

    Please follow-up if you have more questions!
  • Thanks for the tips, I'm going to give them a shot!
  • Travis_PTravis_P Member
    edited December 2018
    OK, the vector has been created and all of the habitat types are now separate shapefiles.  When I run the model I get the following error:

    %s did not load

    This error appears only when running the new csv with "compute regression" checked, otherwise it  runs fine which probably indicates a problem with the csv file.  I've tried relocating the file in a folder that is not buried as deep in my system but I still get the same error.  I also tried running as "polygon_percent_coverage" with no luck either.

    Attached is the log and csv.

    Thanks for helping me along with this.


    Post edited by Travis_P on
  • DaveDave Member, Administrator, NatCap Staff
    @Travis_P, this is interesting. I get that same error if I supply an incorrect path to one of the shapefiles in the table. But it doesn't look like the path listed in the error message appears in your table, so I'm not sure what's going on.

    Could you email me that predictor csv table and I'll take a closer look? 
  • Will do, thanks for your help.

  • DaveDave Member, Administrator, NatCap Staff
    Thanks for sending that along!

    It looks like the culprit are some blank lines at the end of the CSV file. If you open that file in a text editor you'll notice some mostly blank lines at the end with a few commas. The model is concatenating those "spaces" with the predictor table's own file path and interpreting it as another path to a file.

    So, deleting those blank lines and commas should do the trick. Unfortunately they are are hidden when viewing in Excel.
  • Thanks for your help, Dave.  The model is running smoothly now thanks to your suggestions.  No doubt I'll be back on here with more questions as our project moves forward.  Cheers!
Sign In or Register to comment.