Habitat Quaity AttributeError

When I run this model I receiving a “AttributeError” message that says ‘NoneType’ object has no attribute ‘SetGeoTransform’. I have no idea what to do or what it is related to.
log file is included below
2022-05-22 13:57:22,214 (natcap.invest.utils) utils.prepare_workspace(162) Level 100 Writing log messages to F:/GH/0522/SJFX\InVEST-Habitat-Quality-log-2022-05-22–13_57_22.txt
2022-05-22 13:57:22,217 (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:/GH/0522/reClass.tif
n_workers -1
sensitivity_table_path F:/GH/0522/sensituvity.csv
threats_table_path F:/GH/0522/threats.csv
workspace_dir F:/GH/0522/SJFX

2022-05-22 13:57:22,217 (natcap.invest.habitat_quality) habitat_quality.execute(259) INFO Starting execute of Habitat Quality model.
2022-05-22 13:57:22,218 (natcap.invest.habitat_quality) habitat_quality.execute(265) INFO Creating workspace
2022-05-22 13:57:22,276 (natcap.invest.habitat_quality) habitat_quality.execute(278) INFO Checking Threat and Sensitivity tables for compliance
2022-05-22 13:57:22,293 (natcap.invest.habitat_quality) habitat_quality.execute(305) INFO Validate threat rasters and collect unique LULC codes
2022-05-22 13:57:22,293 (natcap.invest.habitat_quality) habitat_quality.execute(323) DEBUG Validating path for threat: crop
2022-05-22 13:57:23,032 (natcap.invest.habitat_quality) habitat_quality.execute(323) DEBUG Validating path for threat: home
2022-05-22 13:57:23,632 (natcap.invest.habitat_quality) habitat_quality.execute(323) DEBUG Validating path for threat: road
2022-05-22 13:57:24,210 (natcap.invest.habitat_quality) habitat_quality.execute(367) INFO Checking threat raster values are valid ( 0 <= x <= 1 ).
2022-05-22 13:57:24,212 (natcap.invest.habitat_quality) habitat_quality.execute(378) INFO Aligning and resizing land cover and threat rasters
2022-05-22 13:57:24,219 (natcap.invest.habitat_quality) habitat_quality.execute(401) DEBUG Raster paths for aligning: [‘F:/GH/0522/SJFX\intermediate\reClass_aligned.tif’, ‘F:/GH/0522/SJFX\intermediate\crop_c_aligned.tif’, ‘F:/GH/0522/SJFX\intermediate\home_c_aligned.tif’, ‘F:/GH/0522/SJFX\intermediate\road_c_aligned.tif’]
2022-05-22 13:57:24,272 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(697) DEBUG assuming manual bounding box mode of [119.91729498301636, 35.62199682316142, 119.93583441172736, 35.63953578790986]
2022-05-22 13:57:25,872 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 1 of 4 aligned: reClass_aligned.tif
2022-05-22 13:57:27,040 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 2 of 4 aligned: crop_c_aligned.tif
2022-05-22 13:57:28,257 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 3 of 4 aligned: home_c_aligned.tif
2022-05-22 13:57:29,469 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 4 of 4 aligned: road_c_aligned.tif
2022-05-22 13:57:29,469 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(828) INFO aligned all 4 rasters.
2022-05-22 13:57:29,578 (natcap.invest.habitat_quality) habitat_quality.execute(413) DEBUG Updating dict raster paths to reflect aligned paths
2022-05-22 13:57:29,578 (natcap.invest.habitat_quality) habitat_quality.execute(431) INFO Starting habitat_quality biophysical calculations
2022-05-22 13:57:30,355 (natcap.invest.habitat_quality) habitat_quality.execute(475) INFO Calculating habitat quality for landuse: F:/GH/0522/SJFX\intermediate\reClass_aligned.tif
2022-05-22 13:57:30,372 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(396) INFO starting stats_worker
2022-05-22 13:57:30,406 (pygeoprocessing.geoprocessing_core) threading.run(870) DEBUG stats worker PID: 14304
2022-05-22 13:57:30,406 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(402) INFO started stats_worker <Thread(Thread-103, started daemon 15132)>
2022-05-22 13:57:31,874 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(482) INFO 100.0% complete
2022-05-22 13:57:31,874 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(485) INFO Waiting for raster stats worker result.
2022-05-22 13:57:32,643 (natcap.invest.habitat_quality) habitat_quality.execute(509) DEBUG Calculating threat: crop.
Threat data: {‘threat’: ‘crop’, ‘max_dist’: 1, ‘weight’: 0.2, ‘decay’: ‘linear’, ‘cur_path’: ‘crop_c.tif’}
2022-05-22 13:57:32,650 (natcap.invest.habitat_quality) habitat_quality._create_decay_kernel(881) DEBUG Max distance in pixels: 372827022.2210791
2022-05-22 13:57:32,664 (osgeo) utils._log_gdal_errors(98) ERROR [errno 3] F:/GH/0522/SJFX\intermediate\kernels\kernel_crop_c.tif: Free disk space available is 300829720576 bytes, whereas 2223999819299448064 are at least necessary. You can disable this check by defining the CHECK_DISK_FREE_SPACE configuration option to FALSE.
2022-05-22 13:57:32,665 (taskgraph.Task) Task.add_task(706) ERROR Something went wrong when adding task decay_kernel_linear_c_crop (6), 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\habitat_quality.py”, line 946, in _make_linear_decay_kernel_path
AttributeError: ‘NoneType’ object has no attribute ‘SetGeoTransform’
2022-05-22 13:57:32,672 (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\habitat_quality.py”, line 946, in _make_linear_decay_kernel_path
AttributeError: ‘NoneType’ object has no attribute ‘SetGeoTransform’
2022-05-22 13:57:32,673 (natcap.invest.utils) utils.prepare_workspace(170) INFO Elapsed time: 10.46s
2022-05-22 13:57:32,674 (natcap.invest.utils) utils.prepare_workspace(173) INFO Execution finished

InVEST version

Hi @yaohui -

It’s often useful to look at earlier log file messages (not just the last one) to see what might be going wrong. In this case, I see this message:

ERROR [errno 3] F:/GH/0522/SJFX\intermediate\kernels\kernel_crop_c.tif: Free disk space available is 300829720576 bytes, whereas 2223999819299448064 are at least necessary.

I’m not sure that this is causing the final SetGeoTransform error, but it’s possible, since we do tend to get weird errors when running out of disk space.

Are your input rasters very large, or very high-resolution? Or, what is the coordinate system of your rasters? They need to have a projected coordinate system (with linear units of meters), not a geographic coordinate system (with units of degrees). This coordinate system requirement should be in the User Guide, but doesn’t seem to be currently, so I’ll go fix that.

~ Stacie

I agree there is probably an issue with a coordinate system. These messages from the log are telling:

A max_dist of 1km equals ~373 million pixels. This means the pixel size of the input LULC raster is impossibly small. Perhaps the coordinates are measured in decimal degrees, but the coordinate system is incorrectly defined to be a system that uses units of meters?

This could represent the common problem of accidentally re-defining a projection instead actually re-projecting. Please see this similar example: OverflowError:in method 'Driver_Create', argument 3 of type 'int' - #6 by dave

Thanks for your suggestions, I have solved the promblem.

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