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

'NoneType' object has no attribute 'GetLayer' in HRA Model Version 3.6.0

CamilleCamille Member
edited February 12 in General
Hi,
I am a land use planning professional attached to thenational planning agency in my country. We are looking at ways to improve on evidence based decision making and have found the natural capital project useful. I am new to the Invest modelling process. My query is specific to the use of the HRA as well as the sample data for the Model (both 3.6.0 version).

There seems to be a problem with the subregion shapefile. The first error indicated Name was not included and was required. I checked the subregion shp in QGIS and Name is there in the attribute table. 

So I redid the entire process and now I am getting this error. 

Initializing...

Showing messages with level INFO and higher

02/12/2019 12:52:07 natcap.invest.utils INFO Writing log messages to C:\Users\camil\Documents\hra_workspace\InVEST-Habitat-Risk-Assessment-log-2019-02-12--12_52_07.txt

02/12/2019 12:52:07 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.habitat_risk_assessment.hra 3.6.0:

aoi_tables C:/Users/camil/Desktop/HabitatRiskAssess/Input/subregions.shp

csv_uri C:\Users\camil\Desktop\hra_preprocessor_workspace\habitat_stressor_ratings

decay_eq None

grid_size 200

max_rating 3

max_stress 2

n_workers -1

results_suffix

risk_eq Euclidean

workspace_dir C:\Users\camil\Documents\hra_workspace


02/12/2019 12:52:07 osgeo ERROR [errno 4] Unable to open C:\Users\camil\Desktop\Test folders for INVEST Model\HabitatLayers\DSGA_POLY.shx or C:\Users\camil\Desktop\Test folders for INVEST Model\HabitatLayers\DSGA_POLY.SHX.Try --config SHAPE_RESTORE_SHX true to restore or create it

02/12/2019 12:52:07 natcap.invest.ui.model ERROR Exception while executing <function execute at 0x13CAF930>

Traceback (most recent call last):

File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\env\lib\site-packages\natcap\invest\ui\model.py", line 1579, in _logged_target

File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\env\lib\site-packages\natcap\invest\habitat_risk_assessment\hra.py", line 316, in execute

File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\env\lib\site-packages\natcap\invest\pygeoprocessing_0_3_3\geoprocessing.py", line 1798, in get_datasource_bounding_box

AttributeError: 'NoneType' object has no attribute 'GetLayer'

02/12/2019 12:52:07 natcap.invest.ui.model INFO Execution finished

02/12/2019 12:52:07 natcap.invest.utils INFO Elapsed time: 0.09s

02/12/2019 12:52:07 natcap.invest.ui.execution ERROR Target <function _logged_target at 0x1432CE30> failed with exception

Traceback (most recent call last):

File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\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\env\lib\site-packages\natcap\invest\ui\model.py", line 1579, in _logged_target

File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\env\lib\site-packages\natcap\invest\habitat_risk_assessment\hra.py", line 316, in execute

File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\env\lib\site-packages\natcap\invest\pygeoprocessing_0_3_3\geoprocessing.py", line 1798, in get_datasource_bounding_box

AttributeError: 'NoneType' object has no attribute 'GetLayer'

02/12/2019 12:52:07 natcap.invest.ui.execution INFO Execution finished


I didnt attach any data as this is the data I downloaded from the website for HRA.

Can you assist?


Camille

Post edited by Camille on

Comments

  • DaveDave Member, Administrator, NatCap Staff
    Hi Camille,

    Is it possible your "DSGA_POLY.shp" somehow lost it's "DSGA_POLY.shx" file? Shapefiles are composed of several different files that all need to be located next to each. If you look in your file system (e.g. Windows Explorer) you should see DSGA_POLY.shp, DSGA_POLY.shx, DSGA_POLY.dbf, DSGA_POLY.prj and maybe others. The error suggests maybe the ".shx" file is missing. If so, maybe you can go back to the original source of the shapefile?
  • Hi again,


    Thanks for that. I downloaded all the data over and kept them together and ran the model. It indicated the run was successfull but I observed in the log a series of errors despite the successful run. The recurrent error seemed to be:


    'Failed to compute statistics, no valid pixels found in sampling.' (see log below)


    I did manage to view some risk plots in QGIS, but I noticed the ecosystem risk raster was displayed in balck and white.

    Would this have anything to do with the buffers and criteria scores I would have input into the CSVs created by the HRA preposessor?


    Camille.


    Initializing...

    Showing messages with level INFO and higher

    02/24/2019 12:44:44 natcap.invest.utils INFO Writing log messages to C:\Users\camil\Desktop\HRASampleData\InVEST-Habitat-Risk-Assessment-log-2019-02-24--12_44_44.txt

    02/24/2019 12:44:44 natcap.invest.ui.model Level 100 Starting model with parameters:

    Arguments for InVEST natcap.invest.habitat_risk_assessment.hra 3.6.0:

    aoi_tables C:/Users/camil/Desktop/HRASampleData/HabitatRiskAssess/Input/subregions.shp

    csv_uri C:\Users\camil\Desktop\HRASampleData\habitat_stressor_ratings

    decay_eq None

    grid_size 200

    max_rating 3

    max_stress 4

    n_workers -1

    results_suffix

    risk_eq Euclidean

    workspace_dir C:\Users\camil\Desktop\HRASampleData


    02/24/2019 12:44:45 natcap.invest.habitat_risk_assessment.hra INFO Rasterizing shapefile layers.

    02/24/2019 12:44:49 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 1

    02/24/2019 12:44:49 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 2

    02/24/2019 12:44:50 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 1

    02/24/2019 12:44:50 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 2

    02/24/2019 12:44:51 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 1

    02/24/2019 12:44:51 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 2

    02/24/2019 12:44:52 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 1

    02/24/2019 12:44:52 natcap.invest.pygeoprocessing_0_3_3.geoprocessing_cython INFO Distance Transform Phase 2

    02/24/2019 12:44:54 osgeo ERROR [errno 1] C:\Users\camil\Desktop\HRASampleData\intermediate\Overlap_Rasters\H[hardbottom]_S[FinfishAquacultureComm].tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:44:55 osgeo ERROR [errno 1] C:\Users\camil\Desktop\HRASampleData\intermediate\Overlap_Rasters\H[kelp]_S[ShellfishAquacultureComm].tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:44:58 natcap.invest.habitat_risk_assessment.hra_core INFO Applying CSV criteria to rasters.

    02/24/2019 12:45:00 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmpdzh1iz.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:00 osgeo ERROR [errno 1] C:\Users\camil\Desktop\HRASampleData\intermediate\ReBurned_Crit_Rasters\H[hardbottom]_S[FinfishAquacultureComm]_Indiv_C_Raster.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:00 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmpd6fhl5.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:00 osgeo ERROR [errno 1] C:\Users\camil\Desktop\HRASampleData\intermediate\ReBurned_Crit_Rasters\H[kelp]_S[ShellfishAquacultureComm]_Indiv_C_Raster.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:05 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmptclofh.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:05 osgeo ERROR [errno 1] C:\Users\camil\Desktop\HRASampleData\intermediate\ReBurned_Crit_Rasters\H[hardbottom]_S[FinfishAquacultureComm]_Indiv_E_Raster.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:06 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmpfrc4pf.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:06 osgeo ERROR [errno 1] C:\Users\camil\Desktop\HRASampleData\intermediate\ReBurned_Crit_Rasters\H[kelp]_S[ShellfishAquacultureComm]_Indiv_E_Raster.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:09 natcap.invest.habitat_risk_assessment.hra_core INFO Calculating risk rasters for individual overlaps.

    02/24/2019 12:45:09 py.warnings WARNING C:\Users\camil\Desktop\INVEST~1\INVEST~1.0_X\INVEST~1\natcap\invest\habitat_risk_assessment\hra_core.py:1728: RuntimeWarning: invalid value encountered in divide


    02/24/2019 12:45:09 py.warnings WARNING C:\Users\camil\Desktop\INVEST~1\INVEST~1.0_X\INVEST~1\natcap\invest\habitat_risk_assessment\hra_core.py:1828: RuntimeWarning: invalid value encountered in divide


    02/24/2019 12:45:12 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmp7qvdv3.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:14 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmp5cxios.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:22 natcap.invest.habitat_risk_assessment.hra_core INFO Calculating habitat risk rasters.

    02/24/2019 12:45:25 natcap.invest.habitat_risk_assessment.hra_core INFO Making risk shapefiles.

    02/24/2019 12:45:37 natcap.invest.habitat_risk_assessment.hra_core INFO Calculating ecosystem risk rasters.

    02/24/2019 12:45:38 py.warnings WARNING C:\Users\camil\Desktop\INVEST~1\INVEST~1.0_X\INVEST~1\natcap\invest\habitat_risk_assessment\hra_core.py:927: RuntimeWarning: invalid value encountered in divide


    02/24/2019 12:45:39 natcap.invest.habitat_risk_assessment.hra_core INFO Creating subregion maps and risk plots.

    02/24/2019 12:45:45 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmpbjxiix, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:47 osgeo ERROR [errno 1] c:\users\camil\appdata\local\temp\tmpnhslyp, band 1: Failed to compute statistics, no valid pixels found in sampling.

    02/24/2019 12:45:57 natcap.invest.ui.model INFO Execution finished

    02/24/2019 12:45:57 natcap.invest.utils INFO Elapsed time: 1m 12.91s

    02/24/2019 12:45:57 natcap.invest.ui.execution INFO Execution finished

    02/24/2019 12:47:33 natcap.invest.ui.inputs INFO Opening file explorer to workspace directory

    02/24/2019 12:47:33 natcap.invest.ui.inputs INFO Using windows explorer to view files



























































  • DaveDave Member, Administrator, NatCap Staff
    The 'Failed to compute statistics' messages you see are not necessarily anything to worry about. The black & white you mention is likely just the default way your GIS software displays the raster. You can use the layer properties menu to assign a different style. Do your results seem to make sense otherwise? 
Sign In or Register to comment.