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

Crop Production model error.

Hello,

I am having serious problems using the Crop Production Model:
I've tried with diferent rasters for the land cover map, and I always get an error message. So I've decided to try with the sample data, and I still get the same error:

AttributeError encountered: 'NoneType' object has no attribute 'GetLayer' See the log for details.

I've tried with InVest 3.4.2, and I've just downloaded and tried the 3.4.4 version with the same results. I've introduced the following sample data, as required (for percentile):
-directory to model data: ....\model_data
-land cover map: ...../sample_user_data/landcover.tif
-land cover to crop table: ....../sample_user_data/landcover_to_crop_table.csv

There are just 3 inputs, and I can't see what could be the error, they are just the sample files! I guess it's the raster, but I don't know. Any thoughts? Have you ever tried to run that model??
(by the way, I also tried the regression model with the same results)

Here is the full log:


Initializing...
Showing messages with level INFO and higher
04/16/2018 18:44:43  natcap.invest.utils INFO     Writing log messages to C:\Users\HPDV6\Documents\crop_production_percentile_workspace\InVEST-Crop-Production-Percentile-Model-log-2018-04-16--18_44_43.txt
04/16/2018 18:44:43  natcap.invest.ui.usage ERROR    Error when transforming coordinates: local variable 'spatial_ref' referenced before assignment
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\usage.py", line 176, in _merge_local_bounding_boxes
UnboundLocalError: local variable 'spatial_ref' referenced before assignment
04/16/2018 18:44:43  natcap.invest.ui.model Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.crop_production_percentile 3.4.4:
aggregate_polygon_id         
aggregate_polygon_path       
landcover_raster_path        C:/Program Files (x86)/InVEST_3.4.4_x86/CropProduction/sample_user_data/landcover.tif
landcover_to_crop_table_path C:/Program Files (x86)/InVEST_3.4.4_x86/CropProduction/sample_user_data/landcover_to_crop_table.csv
model_data_path              C:\Program Files (x86)\InVEST_3.4.4_x86\CropProduction\model_data
results_suffix               
workspace_dir                C:\Users\HPDV6\Documents\crop_production_percentile_workspace

04/16/2018 18:44:43  natcap.invest.ui.usage ERROR    Error when transforming coordinates: local variable 'spatial_ref' referenced before assignment
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\usage.py", line 176, in _merge_local_bounding_boxes
UnboundLocalError: local variable 'spatial_ref' referenced before assignment
04/16/2018 18:44:43  natcap.invest.ui.usage ERROR    Error when transforming coordinates: local variable 'spatial_ref' referenced before assignment
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\usage.py", line 176, in _merge_local_bounding_boxes
UnboundLocalError: local variable 'spatial_ref' referenced before assignment
04/16/2018 18:44:43  natcap.invest.ui.usage ERROR    Error when transforming coordinates: local variable 'spatial_ref' referenced before assignment
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\usage.py", line 176, in _merge_local_bounding_boxes
UnboundLocalError: local variable 'spatial_ref' referenced before assignment
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Processing crop wheat
04/16/2018 18:44:43  natcap.invest.ui.usage ERROR    Error when transforming coordinates: local variable 'spatial_ref' referenced before assignment
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\usage.py", line 176, in _merge_local_bounding_boxes
UnboundLocalError: local variable 'spatial_ref' referenced before assignment
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Clipping global climate bin raster to landcover bounding box.
04/16/2018 18:44:43  natcap.invest.ui.usage ERROR    Error when transforming coordinates: local variable 'spatial_ref' referenced before assignment
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\usage.py", line 176, in _merge_local_bounding_boxes
UnboundLocalError: local variable 'spatial_ref' referenced before assignment
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Map yield_95th to climate bins.
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Interpolate wheat yield_95th yield raster to landcover resolution.
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Calculate yield for wheat at yield_95th
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Map yield_25th to climate bins.
04/16/2018 18:44:43  natcap.invest.crop_production_percentile INFO     Interpolate wheat yield_25th yield raster to landcover resolution.
04/16/2018 18:44:44  natcap.invest.crop_production_percentile INFO     Calculate yield for wheat at yield_25th
04/16/2018 18:44:44  natcap.invest.crop_production_percentile INFO     Map yield_75th to climate bins.
04/16/2018 18:44:45  natcap.invest.crop_production_percentile INFO     Interpolate wheat yield_75th yield raster to landcover resolution.
04/16/2018 18:44:45  natcap.invest.crop_production_percentile INFO     Calculate yield for wheat at yield_75th
04/16/2018 18:44:45  natcap.invest.crop_production_percentile INFO     Map yield_50th to climate bins.
04/16/2018 18:44:45  natcap.invest.crop_production_percentile INFO     Interpolate wheat yield_50th yield raster to landcover resolution.
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Calculate yield for wheat at yield_50th
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Calculating production area.
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Calculate observed yield for wheat
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Interpolating observed wheat raster to landcover.
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Processing crop barley
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Clipping global climate bin raster to landcover bounding box.
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Map yield_95th to climate bins.
04/16/2018 18:44:46  natcap.invest.crop_production_percentile INFO     Interpolate barley yield_95th yield raster to landcover resolution.
04/16/2018 18:44:47  natcap.invest.crop_production_percentile INFO     Calculate yield for barley at yield_95th
04/16/2018 18:44:47  natcap.invest.crop_production_percentile INFO     Map yield_25th to climate bins.
04/16/2018 18:44:47  natcap.invest.crop_production_percentile INFO     Interpolate barley yield_25th yield raster to landcover resolution.
04/16/2018 18:44:47  natcap.invest.crop_production_percentile INFO     Calculate yield for barley at yield_25th
04/16/2018 18:44:47  natcap.invest.crop_production_percentile INFO     Map yield_75th to climate bins.
04/16/2018 18:44:47  natcap.invest.crop_production_percentile INFO     Interpolate barley yield_75th yield raster to landcover resolution.
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Calculate yield for barley at yield_75th
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Map yield_50th to climate bins.
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Interpolate barley yield_50th yield raster to landcover resolution.
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Calculate yield for barley at yield_50th
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Calculating production area.
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Calculate observed yield for barley
04/16/2018 18:44:48  natcap.invest.crop_production_percentile INFO     Interpolating observed barley raster to landcover.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Processing crop soybean
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Clipping global climate bin raster to landcover bounding box.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Map yield_95th to climate bins.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Interpolate soybean yield_95th yield raster to landcover resolution.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Calculate yield for soybean at yield_95th
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Map yield_25th to climate bins.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Interpolate soybean yield_25th yield raster to landcover resolution.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Calculate yield for soybean at yield_25th
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Map yield_75th to climate bins.
04/16/2018 18:44:49  natcap.invest.crop_production_percentile INFO     Interpolate soybean yield_75th yield raster to landcover resolution.
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Calculate yield for soybean at yield_75th
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Map yield_50th to climate bins.
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Interpolate soybean yield_50th yield raster to landcover resolution.
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Calculate yield for soybean at yield_50th
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Calculating production area.
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Calculate observed yield for soybean
04/16/2018 18:44:50  pygeoprocessing.geoprocessing WARNING  Stats not calculated for C:\Users\HPDV6\Documents\crop_production_percentile_workspace\intermediate_output\soybean_clipped_observed_yield.tif band 1 since no non-nodata pixels were found.
04/16/2018 18:44:50  natcap.invest.crop_production_percentile INFO     Interpolating observed soybean raster to landcover.
04/16/2018 18:44:51  natcap.invest.crop_production_percentile INFO     Generating report table
04/16/2018 18:44:51  natcap.invest.crop_production_percentile INFO     aggregating result over query polygon
04/16/2018 18:44:51  natcap.invest.ui.model ERROR    Exception while executing <function execute at 0x13C90FB0>
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 1505, in _logged_target
  File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\crop_production_percentile.py", line 420, in execute
  File "site-packages\pygeoprocessing\geoprocessing.py", line 1075, in reproject_vector
AttributeError: 'NoneType' object has no attribute 'GetLayer'
04/16/2018 18:44:51  natcap.invest.ui.model INFO     Execution finished
04/16/2018 18:44:51  natcap.invest.utils INFO     Elapsed time: 8.14s
04/16/2018 18:44:51  natcap.invest.ui.execution ERROR    Target <function _logged_target at 0x0239FFB0> failed with exception
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\execution.py", line 68, in run
  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 1505, in _logged_target
  File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\crop_production_percentile.py", line 420, in execute
  File "site-packages\pygeoprocessing\geoprocessing.py", line 1075, in reproject_vector
AttributeError: 'NoneType' object has no attribute 'GetLayer'
04/16/2018 18:44:51  natcap.invest.ui.execution INFO     Execution finished


Thank you very much for your help.

Comments

  • RichRich Administrator, NatCap Staff
    Yikes, yes I can verify that I get this error too. This might take a little work so I'll post back here soon.
  • Thank you very much. If there's any way I can help, please let me know.
  • RichRich Administrator, NatCap Staff
    Hi @camilo, I'm sorry I let this get away from me. It looks like we fixed this error a while back and the fix is in the most recent version of InVEST (3.5.0 right now). Would you be willing to try the most recent version and let us know if you run into any problems? https://naturalcapitalproject.stanford.edu/invest/
Sign In or Register to comment.