How can I solve AttributeError: 'NoneType' object has no attribute 'SetGeoTransform'

Hi I’m trying to use InVEST software to analysis Habitat Quality for Protected Area
But I met the error message
AttributeError: ‘NoneType’ object has no attribute ‘SetGeoTransform’
how can I solve this problem?

2022-08-22 20:21:57,362 (natcap.invest.utils) utils.prepare_workspace(162) Level 100 Writing log messages to [E:/HabitatQuality/Taean_HQ_practice\InVEST-Habitat-Quality-log-2022-08-22–20_21_57.txt]
2022-08-22 20:21:57,366 (natcap.invest.ui.model) model._logged_target(1626) Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.habitat_quality 3.11.0:
half_saturation_constant 0.5
lulc_cur_path D:/Habitat_Quality/analysis/LULC_current.tif
n_workers -1
results_suffix
sensitivity_table_path D:/Habitat_Quality/analysis/Sensitivity_Natioanlparks.csv
threats_table_path D:/Habitat_Quality/analysis/Threats_Natioanlparks.csv
workspace_dir E:/HabitatQuality/Taean_HQ_practice

2022-08-22 20:21:57,370 (natcap.invest.habitat_quality) habitat_quality.execute(261) INFO Starting execute of Habitat Quality model.
2022-08-22 20:21:57,370 (natcap.invest.habitat_quality) habitat_quality.execute(267) INFO Creating workspace
2022-08-22 20:21:57,375 (natcap.invest.habitat_quality) habitat_quality.execute(280) INFO Checking Threat and Sensitivity tables for compliance
2022-08-22 20:21:57,389 (natcap.invest.habitat_quality) habitat_quality.execute(307) INFO Validate threat rasters and collect unique LULC codes
2022-08-22 20:21:57,389 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: urban
2022-08-22 20:21:57,395 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: industry
2022-08-22 20:21:57,399 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: road
2022-08-22 20:21:57,403 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: agri
2022-08-22 20:21:57,411 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: paddy
2022-08-22 20:21:57,415 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: dry
2022-08-22 20:21:57,418 (natcap.invest.habitat_quality) habitat_quality.execute(325) DEBUG Validating path for threat: bare
2022-08-22 20:21:57,421 (natcap.invest.habitat_quality) habitat_quality.execute(369) INFO Checking threat raster values are valid ( 0 <= x <= 1 ).
2022-08-22 20:21:57,422 (natcap.invest.habitat_quality) habitat_quality.execute(380) INFO Aligning and resizing land cover and threat rasters
2022-08-22 20:21:57,443 (natcap.invest.habitat_quality) habitat_quality.execute(403) DEBUG Raster paths for aligning: [‘E:/HabitatQuality/Taean_HQ_practice\intermediate\LULC_current_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\urban_c_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\industry_c_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\road_c_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\agri_c_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\paddy_c_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\dry_c_aligned.tif’, ‘E:/HabitatQuality/Taean_HQ_practice\intermediate\bare_c_aligned.tif’]
2022-08-22 20:21:57,472 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(697) DEBUG assuming manual bounding box mode of [67971.5565, 419792.03, 150711.5565, 489242.03]
2022-08-22 20:21:57,747 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 1 of 8 aligned: LULC_current_aligned.tif
2022-08-22 20:21:57,922 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 2 of 8 aligned: urban_c_aligned.tif
2022-08-22 20:21:58,020 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 3 of 8 aligned: industry_c_aligned.tif
2022-08-22 20:21:58,170 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 4 of 8 aligned: road_c_aligned.tif
2022-08-22 20:21:58,338 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 5 of 8 aligned: agri_c_aligned.tif
2022-08-22 20:21:58,476 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 6 of 8 aligned: paddy_c_aligned.tif
2022-08-22 20:21:58,647 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 7 of 8 aligned: dry_c_aligned.tif
2022-08-22 20:21:58,871 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(824) INFO 8 of 8 aligned: bare_c_aligned.tif
2022-08-22 20:21:58,872 (pygeoprocessing.geoprocessing) geoprocessing.align_and_resize_raster_stack(828) INFO aligned all 8 rasters.
2022-08-22 20:21:58,947 (natcap.invest.habitat_quality) habitat_quality.execute(415) DEBUG Updating dict raster paths to reflect aligned paths
2022-08-22 20:21:58,947 (natcap.invest.habitat_quality) habitat_quality.execute(433) INFO Starting habitat_quality biophysical calculations
2022-08-22 20:21:59,131 (natcap.invest.habitat_quality) habitat_quality.execute(477) INFO Calculating habitat quality for landuse: E:/HabitatQuality/Taean_HQ_practice\intermediate\LULC_current_aligned.tif
2022-08-22 20:21:59,148 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(396) INFO starting stats_worker
2022-08-22 20:21:59,149 (pygeoprocessing.geoprocessing_core) threading.run(946) DEBUG stats worker PID: 3800
2022-08-22 20:21:59,149 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(402) INFO started stats_worker <Thread(Thread-514 (stats_worker), started daemon 12140)>
2022-08-22 20:21:59,279 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(482) INFO 100.0% complete
2022-08-22 20:21:59,279 (pygeoprocessing.geoprocessing) geoprocessing.raster_calculator(485) INFO Waiting for raster stats worker result.
2022-08-22 20:21:59,532 (natcap.invest.habitat_quality) habitat_quality.execute(511) DEBUG Calculating threat: urban.
Threat data: {‘threat’: ‘urban’, ‘max_dist’: 10000, ‘weight’: 1.0, ‘decay’: ‘exponential’, ‘description’: ‘urbanization and drying area’, ‘cur_path’: ‘urban_c.tif’}
2022-08-22 20:21:59,543 (natcap.invest.habitat_quality) habitat_quality._create_decay_kernel(883) DEBUG Max distance in pixels: 333333.3333333333
2022-08-22 20:21:59,544 (osgeo) utils._log_gdal_errors(98) ERROR [errno 3] E:/HabitatQuality/Taean_HQ_practice\intermediate\kernels\kernel_urban_c.tif: Free disk space available is 896767815680 bytes, whereas 44444462222224 are at least necessary. You can disable this check by defining the CHECK_DISK_FREE_SPACE configuration option to FALSE.
2022-08-22 20:21:59,546 (taskgraph.Task) Task.add_task(706) ERROR Something went wrong when adding task decay_kernel_exponential_c_urban (10), 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 897, in _create_decay_kernel
File “natcap\invest\utils.py”, line 358, in exponential_decay_kernel_raster
AttributeError: ‘NoneType’ object has no attribute ‘SetGeoTransform’
2022-08-22 20:21:59,555 (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 1632, in _logged_target
File “natcap\invest\habitat_quality.py”, line 536, 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 897, in _create_decay_kernel
File “natcap\invest\utils.py”, line 358, in exponential_decay_kernel_raster
AttributeError: ‘NoneType’ object has no attribute ‘SetGeoTransform’
2022-08-22 20:21:59,559 (natcap.invest.utils) utils.prepare_workspace(170) INFO Elapsed time: 2.19s
2022-08-22 20:21:59,559 (natcap.invest.utils) utils.prepare_workspace(173) INFO Execution finished

Hi @tjdgml -

If you look through the log file, you’ll see this error message:

ERROR [errno 3] E:/HabitatQuality/Taean_HQ_practice\intermediate\kernels\kernel_urban_c.tif: Free disk space available is 896767815680 bytes, whereas 44444462222224 are at least necessary.

So it looks like you don’t have enough disk space, and that may be leading to the obscure error message at the end.

That’s a lot of disk space, so I’m guessing that you’re using very high-resolution input data, and/or have a very large threat distance, and/or your input data is in a geographic coordinate system, instead of a projected coordinate system, which is required by the model.

If you need more information, first try doing a search on this forum. This topic has come up several times previously, and those posts may help.

~ Stacie

2 Likes