Coastal Vulnerability: SystemError: <built-in function len> returned a result with an exception set

What is the issue or question you have?

What do you expect to happen?

What have you tried so far?

Attach the logfile here:

Hello.
I was using InVEST_3.10.2_x64 to run the sample data of coastal vulnerability, but it couldn’t work. The last time I use it, it seems fine. Hope someone else could help me with this, thank you!
At first, I thought I might need the latest version of Invest. So I installed the Invest workbench, but still receive the same error message listed as below:

01/26/2023 08:12:51 natcap.invest.utils Level 100 Writing log messages to [E:\testt\InVEST-natcap.invest.coastal_vulnerability-log-2023-01-26–08_12_51.txt]
01/26/2023 08:12:51 main Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.coastal_vulnerability 3.12.1:
aoi_vector_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\aoi_grandbahama_utm.shp
bathymetry_raster_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\bathymetry.tif
dem_averaging_radius 5000
dem_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\dem_srtm_grandbahama.tif
geomorphology_fill_value 5
geomorphology_vector_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\geomorphology_grandbahama.shp
habitat_table_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\GrandBahama_Habitats\Natural_Habitats.csv
landmass_vector_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\landmass_polygon.shp
max_fetch_distance 10000
model_resolution 200
n_workers -1
population_radius 1000
population_raster_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\population_grandbahama.tif
results_suffix
shelf_contour_vector_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\continental_shelf_polyline_global.shp
slr_field SLR
slr_vector_path
workspace_dir E:\testt
wwiii_vector_path E:\Software Installation\InVEST\sample_data\CoastalVulnerability\WaveWatchIII_global.shp

01/26/2023 08:12:51 natcap.invest.coastal_vulnerability INFO Validating arguments
01/26/2023 08:12:51 natcap.invest.validation INFO Starting whole-model validation with ARGS_SPEC
01/26/2023 08:12:52 pygeoprocessing.geoprocessing INFO starting reprojection
01/26/2023 08:12:52 pygeoprocessing.geoprocessing INFO reprojection 100.0% complete on clipped_projected_landmass.gpkg
01/26/2023 08:12:52 natcap.invest.coastal_vulnerability INFO Masking positive values from bathymetry
01/26/2023 08:12:52 natcap.invest.coastal_vulnerability WARNING E:\Software Installation\InVEST\sample_data\CoastalVulnerability\bathymetry.tif is unprojected and will be warped to match the AOI and resampled to a pixel size of 200.0 meters
01/26/2023 08:12:52 pygeoprocessing.geoprocessing INFO starting stats_worker
01/26/2023 08:12:52 pygeoprocessing.geoprocessing INFO started stats_worker <Thread(Thread-11 (stats_worker), started daemon 5052)>
01/26/2023 08:12:52 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd5 in position 93: invalid continuation byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “pygeoprocessing\geoprocessing.py”, line 415, in raster_calculator
File “osgeo\gdal.py”, line 3743, in ReadAsArray
File “C:\Users\Ziwon\AppData\Local\Temp\embedded.ckdsacoy.zip\shibokensupport_feature_.py”, line 142, in _import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File “osgeo\gdal_array.py”, line 137, in
SystemError: _PyEval_EvalFrameDefault returned a result with an exception set
01/26/2023 08:12:52 pygeoprocessing.geoprocessing INFO Waiting for raster stats worker result.
01/26/2023 08:12:52 pygeoprocessing.geoprocessing_core WARNING No valid pixels were received, sending None.
01/26/2023 08:12:52 taskgraph.Task ERROR Something went wrong when adding task prepare bathymetry (1), terminating taskgraph.
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd5 in position 93: invalid continuation byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in call
File “natcap\invest\coastal_vulnerability.py”, line 1830, in warp_and_mask_bathymetry
File “pygeoprocessing\geoprocessing.py”, line 415, in raster_calculator
File “osgeo\gdal.py”, line 3743, in ReadAsArray
File "C:\Users\Ziwon\AppData\Local\Temp\embedded.ckdsacoy.zip\shibokensupport_feature
.py", line 142, in _import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File “osgeo\gdal_array.py”, line 137, in
SystemError: _PyEval_EvalFrameDefault returned a result with an exception set
01/26/2023 08:12:52 natcap.invest.utils ERROR Exception while executing natcap.invest.coastal_vulnerability
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd5 in position 93: invalid continuation byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

SystemError: <class ‘UnicodeDecodeError’> returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 72, in _log_gdal_errors
SystemError: returned a result with an exception set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 164, in prepare_workspace
File “invest\cli.py”, line 486, in main
File “natcap\invest\coastal_vulnerability.py”, line 457, in execute
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in call
File “natcap\invest\coastal_vulnerability.py”, line 1830, in warp_and_mask_bathymetry
File “pygeoprocessing\geoprocessing.py”, line 415, in raster_calculator
File “osgeo\gdal.py”, line 3743, in ReadAsArray
File "C:\Users\Ziwon\AppData\Local\Temp\embedded.ckdsacoy.zip\shibokensupport_feature
.py", line 142, in _import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File “osgeo\gdal_array.py”, line 137, in
SystemError: _PyEval_EvalFrameDefault returned a result with an exception set
01/26/2023 08:12:52 natcap.invest.utils INFO Elapsed time: 0.91s
01/26/2023 08:12:52 natcap.invest.utils INFO Execution finished

Hi @Ziwon,
The problem is that InVEST requires your CSVs to be encoded in UTF-8. Please see this article for instructions on how to change the encoding of your CSVs: https://support.meistertask.com/hc/en-us/articles/4406395262354-How-Do-I-Encode-My-CSV-File-Using-the-UTF-8-Format-

Hi esoth,

Thank you for your kind reply.
I have tried as you said, still the same Error.
I have also tried other modules in the Invest model with their sample data, also the same error. Is there any module I need to pre-install on my computer?

Thank you.

Hi @Ziwon ,

Thanks for reporting this! This error you’re experiencing has been very difficult for us to reproduce, and so I would very much like your help with debugging this. I have created a development build (download link below) that will produce a lot more debugging information. Could you do the following to try this out?

  1. Download and run this development build of InVEST: https://storage.googleapis.com/natcap-dev-build-artifacts/invest/phargogh/3.12.1.post14%2Bg725c2c5b5/workbench/invest_3.12.1.post14%2Bg725c2c5b5_workbench_win32_x64.exe

  2. Once the development build has installed and launched, configure the logging to have a level of debug. You can do this with the following steps:

    a. Click the gear icon to open the options dialog:

    b. Then, set the logging level to DEBUG. You can leave all other settings alone. Once you have done this, click the X in the upper-right corner to save the options.

Then, run the model again on the sample data and please upload the logfile. I expect there to be a LOT more logging.

Thanks in advance for your help!
James

1 Like

Hi jdouglass

Thank you for your help. I think maybe it’s because some DLL documents missing. I have reset it and the good news is the InVEST model could work now.
But the strange thing is, I changed different sea level rise data, and theoretically the CVI outputs should be different. Yet the results are the same even if I exaggerate the changes in sea levels.

Looking forward to your thoughts.

Hi @Ziwon -

Does your sea level rise (SLR) data change uniformly across your area of interest, or does it change more in some places than others? Because the model only uses relative rankings from 1-5, not absolute values of sea level rise, it doesn’t matter what the actual SLR numbers are, if they change by the same amount across your whole area of interest, you won’t see a difference in results.

~ Stacie

@Ziwon that’s great to hear that the model is working now! Would you please attach the log from the workbench version that I sent you? I think there may be some important debugging information in there that can help us determine the cause of the SystemError.

Thanks,
James

1 Like

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