OverflowError:in method 'Driver_Create', argument 3 of type 'int'

hi, I have this problem in the habitat Quality mode of the invest software. I don’t know what caused it. I didn’t find the answer in the past. I hope someone with good intentions can help me.

02/14/2022 18:23:14  natcap.invest.utils ERROR    Exception while executing Habitat-Quality
Traceback (most recent call last):
 File "natcap\invest\utils.py", line 165, in prepare_workspace
 File "natcap\invest\ui\model.py", line 1649, in _logged_target
 File "natcap\invest\habitat_quality.py", line 534, in execute
 File "taskgraph\Task.py", line 674, in add_task
 File "taskgraph\Task.py", line 1093, in _call
 File "natcap\invest\habitat_quality.py", line 895, in _create_decay_kernel
 File "natcap\invest\utils.py", line 350, in exponential_decay_kernel_raster
 File "osgeo\gdal.py", line 1997, in Create
OverflowError: in method 'Driver_Create', argument 3 of type 'int'

Hi @yangfei , thanks for posting. Please upload your entire logfile from the output workspace.

Uploading: InVEST-Habitat-Quality-log-2022-02-15–16_21_18.txt…
thank you~,I have uploaded the entire logfile in the workplace.

I’m sorry, the upload did not work. I think maybe you need to wait a moment for the “Uploading” message to disappear before submitting the reply. Thank you

sorry~,I don’t know if it worked this time?

2022-02-17 15:36:12,106 (natcap.invest.utils) utils.prepare_workspace(162) Level 100 Writing log messages to C:/Users/杨菲/Desktop/workplace\InVEST-Habitat-Quality-log-2022-02-17--15_36_12.txt
2022-02-17 15:36:12,114 (natcap.invest.ui.model) model._logged_target(1643) Level 100 Starting model with parameters: 
Arguments for InVEST natcap.invest.habitat_quality 3.10.2:
half_saturation_constant 0.5
lulc_cur_path            F:/期刊论文/7未知(2022.05-2022.08)/数据测试/遥感/workplace/landuse_c.tif
n_workers                -1
results_suffix           
sensitivity_table_path   F:/期刊论文/7未知(2022.05-2022.08)/数据测试/遥感/workplace/sensitivty.csv
threats_table_path       F:/期刊论文/7未知(2022.05-2022.08)/数据测试/遥感/workplace/threats/threats.csv
workspace_dir            C:/Users/杨菲/Desktop/workplace

2022-02-17 15:36:12,116 (natcap.invest.habitat_quality) habitat_quality.execute(259) INFO Starting execute of Habitat Quality model.
2022-02-17 15:36:12,116 (natcap.invest.habitat_quality) habitat_quality.execute(265) INFO Creating workspace
2022-02-17 15:36:12,169 (natcap.invest.habitat_quality) habitat_quality.execute(278) INFO Checking Threat and Sensitivity tables for compliance
2022-02-17 15:36:12,186 (natcap.invest.habitat_quality) habitat_quality.execute(305) INFO Validate threat rasters and collect unique LULC codes
2022-02-17 15:36:12,187 (natcap.invest.habitat_quality) habitat_quality.execute(323) DEBUG Validating path for threat: urban
2022-02-17 15:36:13,464 (natcap.invest.habitat_quality) habitat_quality.execute(367) INFO Checking threat raster values are valid ( 0 <= x <= 1 ).
2022-02-17 15:36:13,466 (natcap.invest.habitat_quality) habitat_quality.execute(378) INFO Aligning and resizing land cover and threat rasters
2022-02-17 15:36:13,471 (natcap.invest.habitat_quality) habitat_quality.execute(401) DEBUG Raster paths for aligning: ['C:/Users/杨菲/Desktop/workplace\\intermediate\\landuse_c_aligned.tif', 'C:/Users/杨菲/Desktop/workplace\\intermediate\\urban_c_aligned.tif']
2022-02-17 15:36:13,483 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(697) DEBUG assuming manual bounding box mode of [112.5123013693372, 0.00034797887756348107, 112.51231162954818, 0.00035693496130093663]
2022-02-17 15:36:18,934 (pygeoprocessing.geoprocessing) geoprocessing.logger_callback(3320) INFO Warp 11.0% complete C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:24,712 (pygeoprocessing.geoprocessing) geoprocessing.logger_callback(3320) INFO Warp 22.0% complete C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:29,719 (pygeoprocessing.geoprocessing) geoprocessing.logger_callback(3320) INFO Warp 34.0% complete C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:34,845 (pygeoprocessing.geoprocessing) geoprocessing.logger_callback(3320) INFO Warp 58.0% complete C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:39,926 (pygeoprocessing.geoprocessing) geoprocessing.logger_callback(3320) INFO Warp 85.0% complete C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:42,660 (pygeoprocessing.geoprocessing) geoprocessing.logger_callback(3320) INFO Warp 100.0% complete C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:45,124 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 1 of 2 aligned: landuse_c_aligned.tif
2022-02-17 15:36:45,137 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 2 of 2 aligned: urban_c_aligned.tif
2022-02-17 15:36:45,138 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(828) INFO aligned all 2 rasters.
2022-02-17 15:36:45,152 (natcap.invest.habitat_quality) habitat_quality.execute(413) DEBUG Updating dict raster paths to reflect aligned paths
2022-02-17 15:36:45,152 (natcap.invest.habitat_quality) habitat_quality.execute(431) INFO Starting habitat_quality biophysical calculations
2022-02-17 15:36:49,072 (natcap.invest.habitat_quality) habitat_quality.execute(475) INFO Calculating habitat quality for landuse: C:/Users/杨菲/Desktop/workplace\intermediate\landuse_c_aligned.tif
2022-02-17 15:36:49,204 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(396) INFO starting stats_worker
2022-02-17 15:36:49,211 (pygeoprocessing.geoprocessing_core) threading.run(870) DEBUG stats worker PID: 19592
2022-02-17 15:36:49,212 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(402) INFO started stats_worker <Thread(Thread-58, started daemon 3608)>
2022-02-17 15:36:54,196 (pygeoprocessing.geoprocessing) geoprocessing.<lambda>(477) INFO 94.7% complete
2022-02-17 15:36:54,552 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(482) INFO 100.0% complete
2022-02-17 15:36:54,553 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(485) INFO Waiting for raster stats worker result.
2022-02-17 15:36:56,230 (natcap.invest.habitat_quality) habitat_quality.execute(509) DEBUG Calculating threat: urban.
Threat data: {'threat': 'urban', 'max_dist': 10, 'weight': 1, 'decay': 'exponential', 'cur_path': 'f:\\期刊论文\\7未知(2022.05-2022.08)\\数据测试\\遥感\\workplace\\threats\\urban_c.tif'}
2022-02-17 15:36:56,241 (natcap.invest.habitat_quality) habitat_quality._create_decay_kernel(881) DEBUG Max distance in pixels: 12383760944100.957
2022-02-17 15:36:56,241 (taskgraph.Task) Task.add_task(706) ERROR Something went wrong when adding task decay_kernel_exponential_c_urban (4), terminating taskgraph.
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\habitat_quality.py", line 895, in _create_decay_kernel
  File "natcap\invest\utils.py", line 350, in exponential_decay_kernel_raster
  File "osgeo\gdal.py", line 1997, in Create
OverflowError: in method 'Driver_Create', argument 3 of type 'int'
2022-02-17 15:36:56,247 (natcap.invest.utils) utils.prepare_workspace(167) ERROR Exception while executing Habitat-Quality
Traceback (most recent call last):
  File "natcap\invest\utils.py", line 165, in prepare_workspace
  File "natcap\invest\ui\model.py", line 1649, in _logged_target
  File "natcap\invest\habitat_quality.py", line 534, in execute
  File "taskgraph\Task.py", line 674, in add_task
  File "taskgraph\Task.py", line 1093, in _call
  File "natcap\invest\habitat_quality.py", line 895, in _create_decay_kernel
  File "natcap\invest\utils.py", line 350, in exponential_decay_kernel_raster
  File "osgeo\gdal.py", line 1997, in Create
OverflowError: in method 'Driver_Create', argument 3 of type 'int'
2022-02-17 15:36:56,249 (natcap.invest.utils) utils.prepare_workspace(170) INFO Elapsed time: 44.14s
2022-02-17 15:36:56,249 (natcap.invest.utils) utils.prepare_workspace(173) INFO Execution finished

Thank you, that worked. There is something suspicious about this info from the log:

Threat data: {'threat': 'urban', 'max_dist': 10, 'weight': 1, 'decay': 'exponential', 'cur_path': 'f:\\期刊论文\\7未知(2022.05-2022.08)\\数据测试\\遥感\\workplace\\threats\\urban_c.tif'}
2022-02-17 15:36:56,241 (natcap.invest.habitat_quality) habitat_quality._create_decay_kernel(881) DEBUG Max distance in pixels: 12383760944100.957

This suggests that you specified a max threat distance of 10 kilometers for the “urban” threat. That makes sense. But based on the coordinate system of your LULC raster, 10km = 12 trillion pixels!

My best guess is that your LULC raster has an incorrectly defined coordinate system. Perhaps its coordinates are in decimal degrees, but its coordinate system is interpreting them as meters.

I recommend looking at your data in a GIS and overlaying it with some other data that you know for certain has a correct coordinate system. If your data do not appear in the correct place on earth, then you have this problem.

If you use ArcGIS: arcgis desktop - Layers with same coordinate system should align/overlap in ArcMap but do not? - Geographic Information Systems Stack Exchange

If you use QGIS: coordinate system - Layer disappears when changing from CRS in degrees to CRS in meters in QGIS - Geographic Information Systems Stack Exchange

Also a reminder that both ArcGIS and QGIS do “on the fly reprojection”, which can make your layers look like they overlap in space, and have the same coordinate system, even if they don’t. So be sure to check the layer’s coordinate system in its Properties window, and reproject/warp the layer to a projected coordinate system, if it’s currently in a geographic coordinate system.

~ Stacie

1 Like

Thanks a lot, I have solved the problem~~ :smile:

Thanks, I’ll keep an eye out, thanks a lot~

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