# Negative Values in n\_export for NDR model?

**URL:** <https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488>\
**Category:** Software Support\
**Tags:** ndr\
**Created:** [November 6, 2020, 10:43pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488 "2020-11-06T22:43:56Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [March 9, 2021, 11:26am UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/21 "2021-03-09T11:26:55Z")

</div>

Hi Dave. We filled the nodata holes with the appropriate raster cell values and re-tried the SDR model. We still have negative values in the sed\_exp and other outputs, If you have any further suggestion, it would be appreciated. Thank you.

Gordon  
user: BVIB

---

<div class="post-metadata">

**Author:** ![dave](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/dave/32/70_2.png) [@dave](https://community.naturalcapitalalliance.org/u/dave)\
**Post date:** [March 9, 2021, 1:58pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/22 "2021-03-09T13:58:14Z")

</div>

Hi Gordon, thanks for the update. I assume you mean you still have negative values in the “scenario - baseline” change raster? If so I would compare the two LULCs and confirm that the new crop pixels in the scenario are actually replacing higher retention landcover types. Glancing at the subset of data you shared, I do think there are some “bare ground” and “urban” pixels being converted to crop in the scenario.

---

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [March 9, 2021, 3:47pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/23 "2021-03-09T15:47:22Z")

</div>

Thanks Dave. I am taking a look at it. Appreciated

---

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [March 9, 2021, 5:26pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/24 "2021-03-09T17:26:13Z")

</div>

Hi Dave: the bare ground and urban pixels converted to crop are only 0.2 % of the total watershed area and they are not spatially distributed across all of the watershed area… as our negative values in the “scenario - baseline” change raster are.

I will work it it some more. Thanks for the suggestion.

Gordon

---

<div class="post-metadata">

**Author:** ![dave](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/dave/32/70_2.png) [@dave](https://community.naturalcapitalalliance.org/u/dave)\
**Post date:** [March 12, 2021, 7:33pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/25 "2021-03-12T19:33:58Z")

</div>

Hi @BVIB , the SDR maintainer has graciously weighed in and provided the following feedback after looking at the DEM you shared earlier in this thread.

> - that dem is a 1m resolution. that’s way too small for what the SDR science is derived from. having 1m resolution doesn’t get you a better result and in many ways could give you a misleading result about what 1m pixels were important. SDR is derived from “landscape” level studies that are at least dozens of meters long. so offhand, just for science and numerical reasons i’d coarsen it to 30m

> - the other thing is the floating point resolution on that DEM is 15 decimal places. That extra precision abuts a bug in the DEM pit-filling algorithm that will be fixed in an upcoming release.

Essentially, the precision of the DEM is so high that in some areas the model can’t determine which pixel is higher or lower than the next because the elevation values are too close and being mistaken for equal. That bug will be fixed in an upcoming release, but regardless, it sounds like the way forward is to coarsen the DEM to about 30m and maybe convert it to an integer datatype in the process. Then the DEM will behave appropriately in the SDR model.

---

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [March 13, 2021, 5:05pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/26 "2021-03-13T17:05:02Z")

</div>

Thanks Dave ! The info and advice is greatly appreciated. Thanks to you and to your SDR maintainer for taking the time to look at it for us. We will follow your advice. Appreciated.

Gordon (for a project in NB)  
user: BVIB

---

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [April 6, 2021, 3:29pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/27 "2021-04-06T15:29:51Z")

</div>

Hello

Following up on suggestions that you and a few other InVEST / ROOT people have made to us, we have now made some additional pretreatment to our data to attempt to eliminate some of difficulties we had with the negative values in our scenario change rasters. These input data pretreatments consisted of (as suggested to us):

- All our input data rasters are now all resampled to 30 x 30 resolution to match the ‘’Landscape level’’ functionality of the InVEST models
- Assuring that all rasters are now properly aligned at the pixel levels, with the same extents
- All rasters are now with the nodata exactly spatially matched between input rasters, or eliminated
- The pixel-to-pixel interference of our ‘’Bare Ground’’ and ‘’Urban’’ pixels between our LULC input raster and scenario raster that was causing negative output values in our change scenario (raster to raster subtraction) has been corrected and eliminated (we hope).

Nonetheless, we still have some negative values in our change scenario (raster to raster subtraction) outputs. We believe that this may be p _ossibly_ related to some remaining biophysical table coefficient overlap in our change scenario (raster to raster subtraction).

Questions:

- Do you have any suggestions of methods regarding how we could efficiently screen of biophysical table coefficients for overlap in our change scenario (raster to raster subtraction) ?
- Do you have any other suggestions of places in our work we may look for other potential problems that might be creating negative values in our scenario change rasters ?

We appreciate your assistance! All the advice we have received so far from several people has proven very useful and has helped to us to improve our input data.

Thank you.

Gordon  
_For a project in NB_  
User: BVIB

---

<div class="post-metadata">

**Author:** ![dave](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/dave/32/70_2.png) [@dave](https://community.naturalcapitalalliance.org/u/dave)\
**Post date:** [April 7, 2021, 5:47pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/28 "2021-04-07T17:47:58Z")

</div>

Hi Gordon, sounds like you’ve made some good progress. All that pre-processing sounds very smart and worth doing. FYI that second step of aligning extents and matching pixel sizes is actually something that’s always done by the invest model, usually using the DEM as the one to match all others to. But it never hurts to do it yourself first!

I’m not sure what you mean by:

> [@BVIB](#):
>
> biophysical table coefficient overlap

But in general, if I want to investigate a specific pixel value in the outputs, I load up all the output & intermediate rasters into GIS, zoom into a specific pixel that has a suspect value (e.g. one of those “negative change” pixels) and use the “identify” tool to examine all the values in that location from the intermediate datasets that might be influencing the final value. Maybe that will reveal something.

---

<div class="post-metadata">

**Author:** ![JIahengDu](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@JIahengDu](https://community.naturalcapitalalliance.org/u/JIahengDu)\
**Post date:** [June 7, 2021, 10:38am UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/29 "2021-06-07T10:38:04Z")

</div>

I am facing the same question, are you figure it out??

---

<div class="post-metadata">

**Author:** ![esoth](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@esoth](https://community.naturalcapitalalliance.org/u/esoth)\
**Post date:** [June 7, 2021, 2:35pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/30 "2021-06-07T14:35:31Z")

</div>

@JIahengDu,  
Are the negative values very small and close to zero? If so it may just be numeric imprecision as discussed above. If you can attach your output file, that would be helpful

---

<div class="post-metadata">

**Author:** ![giogarcia.2907](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@giogarcia.2907](https://community.naturalcapitalalliance.org/u/giogarcia.2907)\
**Post date:** [July 21, 2023, 3:33pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/31 "2023-07-21T15:33:47Z")

</div>

Hii  
I have the same problem of the negative values in NDR, my negative values are big and I don’t know what to do about it, I ran the model several times and I get the same result… but I’m pretty sure that my inputs are correct.

Can someone help me please, I will really appreciated  
Giovana

---

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [July 21, 2023, 3:48pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/32 "2023-07-21T15:48:55Z")

</div>

you may possibly need to adjust the coefficients in your biophysical table. check them out. they may be generating a negative result in the model due to the coefficients overlapping to a negative sum. Also ensure that there are no empty cells in your input rasters. good luck.

---

<div class="post-metadata">

**Author:** ![BVIB](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@BVIB](https://community.naturalcapitalalliance.org/u/BVIB)\
**Post date:** [July 21, 2023, 3:55pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/33 "2023-07-21T15:55:53Z")

</div>

Also…check to see that 2 of your input rasters are not subtracting to a negative value. …also…is N loss a valid outcome for your scenario?

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [July 21, 2023, 3:57pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/34 "2023-07-21T15:57:41Z")

</div>

Hello @giogarcia.2907 , I agree with @BVIB’s suggestions. In addition, if the negative values are _very_ large (like `-3.4028235e+38`) this can sometimes be caused by an incorrectly defined nodata value somewhere in your raster stack. Could you check all of your input rasters to NDR and make sure that they all have a nodata value defined and also that the nodata value matches what you would expect for the layer?

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![giogarcia.2907](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@giogarcia.2907](https://community.naturalcapitalalliance.org/u/giogarcia.2907)\
**Post date:** [July 21, 2023, 4:02pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/35 "2023-07-21T16:02:49Z")

</div>

![Untitled](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/9/9f06de3ae063651a8f732ed3d6338ca293c1444d.png)  
Hii thanks for the answer, the min value is -252

---

<div class="post-metadata">

**Author:** ![dcdenu4](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/dcdenu4/32/544_2.png) [@dcdenu4](https://community.naturalcapitalalliance.org/u/dcdenu4)\
**Post date:** [July 27, 2023, 1:57pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/36 "2023-07-27T13:57:37Z")

</div>

Hi @giogarcia.2907,

Would you be able to share all your model data inputs for us to investigate further? This [post](https://community.naturalcapitalalliance.org/t/an-easy-way-to-share-data-using-the-invest-workbench/3879/4) instructs on an easy way to capture all your inputs and share them. You can share a link here to the data or email a link to ddenu@stanford.edu if you’d prefer. Thanks!

Doug

---

<div class="post-metadata">

**Author:** ![giogarcia.2907](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@giogarcia.2907](https://community.naturalcapitalalliance.org/u/giogarcia.2907)\
**Post date:** [July 27, 2023, 6:22pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/37 "2023-07-27T18:22:28Z")

</div>

> [@giogarcia.2907](#):
>
> negative values in NDR

Hii Doug  
Thanks for the answer, I sent you and email with the data inputs.  
If you can help me I would appreciated .

Regards  
Gio

---

<div class="post-metadata">

**Author:** ![dcdenu4](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/dcdenu4/32/544_2.png) [@dcdenu4](https://community.naturalcapitalalliance.org/u/dcdenu4)\
**Post date:** [August 2, 2023, 7:20pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/38 "2023-08-02T19:20:06Z")

</div>

Hi @giogarcia.2907,

Sorry for the delay. I did receive your email and will take a look by the end of the week. Sorry for the slow follow up!

Doug

---

<div class="post-metadata">

**Author:** ![dcdenu4](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/dcdenu4/32/544_2.png) [@dcdenu4](https://community.naturalcapitalalliance.org/u/dcdenu4)\
**Post date:** [August 3, 2023, 3:57pm UTC](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488/39 "2023-08-03T15:57:00Z")

</div>

Hi @giogarcia.2907,

Again, thanks for sharing your data and sorry for the slow response. I noticed that your `eff_n` column had values greater than 1. Those values represent the percentage (as a decimal) of how well the landcover can retain nitrogen. Having values greater than 100% could cause the negative values you are seeing and in fact when changing those values in the table I get results that are all positive.

Let us know if anything else comes up in your use of the model, thanks!

Doug

[Previous page](https://community.naturalcapitalalliance.org/t/negative-values-in-n-export-for-ndr-model/1488.md?page=1)
