HRA summary statistic missing values and 0

Hi Nat cap Team,

I am currently using the [ InVEST 3.10.2] version and I am running the HRA python using R and the reticulate library. I have no error messages when I am running the code and my data are all the British National Grid as coordinate system and meters as units.
However I am ending up with lot of empty cells in the summary statistic excel file and the column R_%HIGH is full of 0 which makes me think that I am might have a problem somewhere. I attached the file to this message, would you have any suggestion to address the problem?


Thanking you in advance

@jdouglass is it worth having @Morgane try the latest dev build of HRA? I know we have an open issue about a problem with the risk classification? Maybe that explains the R_%HIGH zeros?

As for the empty cells, it seems reasonable to think that with so many combinations of habitat-stressor-subregion, some of those cells would be empty when a given habitat-stressor pair simply does not occur in that subregion. Could you spot-check the input data in GIS to see if that explains it?

@dave @jdouglass Thank you for your answer. I checked the GIS and yes it is because habitats-stressors don’t occur in some subregions. Thank you for pointing that out :slightly_smiling_face:. I also ran the model with only two subregions I don’t have empty cells (which makes sense) but ended up with zero E_MIN, R_MIN and R_%HIGH columns but I guess it is due to the problem with risk classification you mentioned.
I attached my outputs to the message.

I would be happy to try any latest version to see if it is addressing the problem.

1 Like

Yes, this sounds exactly like the reclassification issue we recently discovered. The crux of the problem we recently fixed is that an error in the High/Med/Low risk reclassification code was causing most if not all of the habitat pixels to be classified as Low-risk, even when they should have a higher risk classification.

The development build linked below is functionally very similar, but will give slightly different (should be more accurate) results because of a change in how vector-based inputs are rasterized and aligned. It does not currently summarize the statistics per subregion in SUMMARY_STATISTICS.csv, though this should not be difficult to calculate by hand if it is needed.

Please let us know how well this works for you or if anything looks strange!


1 Like

Hi @jdouglass and @dave,

Thank you very much for sharing the file with me.
Yes I got slightly different outputs as raster :slightly_smiling_face:
If I understand correctly your previous message does it mean that the summary_statistic.csv is not usable or is it just the E_MIN, C_MIN and R_%HIGH columns with the development build version? Do you know when the problem would be fixed (I guess it takes time to fix) or when a new code would be available because I am running the source code.

I was also wondering if it was possible for the HRA to accurately estimate the risk if I input nested sets of habitats from local to large scales?

Sorry it might be a lot of questions all at once :sweat_smile:.

Thank you for taking the time to get back to me

I think James will have to answer the questions about what exactly changed in the new version and where you might access the new source code. He’s offline today.

Can you give an example of what you mean by nested sets of habitats from local to large scales? Generally if you want to evaluate things at multiple scales, you would execute the model once for each new set of input data.

All I meant is that the InVEST 3.10.2 version of HRA includes rows in summary_statistics.csv that look like:

corals,(FROM ALL STRESSORS),Total Region,0.6501342879956097,0.0,1.3333334,0.656397533099008,0.25,1.0714285,3.070500495640717,0.0,6.6189623,84.89608123115977,14.358242106933206,0.7456766619070284
corals,agric_runoff,Total Region,0.4031413545991322,0.0,2.3333333,0.2715033353103185,0.0,1.5714285,0.25063124948241644,0.0,1.4506234,0.0,17.277486910994764,82.72251308900523

The line that includes corals,(FROM ALL STRESSORS), Total Region is not currently calculated. It will be, I just haven’t gotten to it yet. The rest of the table should be complete and correct.

I’d guess I’ll need a couple more weeks or so to finish up a few other things in HRA before this might go into our main branch, but you could install my development version within your python installation like so:

pip uninstall -y natcap.invest
pip install "git+"

If that pip install gives you troubles with GDAL versions, you could try pip install --no-deps "git+". Note that you’ll need to have a compiler installed, so let me know if you don’t and I can share a python wheel with you for your OS and python version.