How do I calculate nutrient retention in InVEST?
The modified load raster is expressed in kg/year, while the export raster is in kg/ha/ year.
Hi "@taherunnesa. The formula is: Modified. load - N export . you can find modified.load in the “intermediate output” folder.
But the units are not the same. When I converted the modified load from kg/yr to kg/ha/yr by dividing by 0.09, the values became quite large. Then I subtracted the nitrogen export from the modified load to calculate retention. However, the resulting retention map shows unexpectedly higher retention in urban areas compared to wetlands, which doesn’t make sense.
The nitrogen and phosphorus export results in the “watershed_results_ndr.gpkg” shapefile are reported in kg/year, representing the sum of kg/ha/year values across the entire watershed. Although InVEST version 3.16 and later states that export values are calculated in kg/ha/year, the raster outputs are actually expressed in kg/pixel. I have checked it.
For example, if your raster resolution is 30 meters, each pixel represents an area of:
30 × 30 = 900 m², which is equivalent to 0.09 hectares.
Therefore, to accurately summarize nitrogen and phosphorus export using zonal statistics (e.g., by watershed), you must first multiply the raster values by 0.09. If this step is skipped, the zonal statistics will significantly overestimate export values compared to those reported in the “watershed_results_ndr.gpkg” file. This discrepancy occurs because the raster values are per pixel, whereas the shapefile aggregates results per hectare. @swolny ,@Dave, please check it
@Taherunnesa and @Eshetu , I believe the modified load raster is already in units kg/ha/yr. The load values included in the biophysical table input are expected to be kg/ha/yr, and the model no longer does any pixel area conversions when creating raster outputs based on those values. I believe our metadata incorrectly states kg/yr for these intermediate raster outputs. We will fix that.
The watershed vector results are in units of kg/yr - the model does the correct conversion.
Reading your comments, I subtracted the export raster from the modified load, keeping the unit as it is. Still, the retention shows higher in urban areas than in wetlands. Do you know what the possible reasons are? @dave @swolny
"@dave Thank you for your explanation. However, after running the NDR model, I noticed that the N and P export values reported in the watershed_results_ndr.gpkg shapefile were much lower than the values I calculated using zonal statistics by watershed. This led me to suspect that the units of the N and P export rasters were in kg per pixel rather than kg per hectare.
To test this, I multiplied the raster values by 0.09 (the conversion factor for a 30 m pixel to hectares). After this adjustment, the sum of N and P export values obtained using zonal statistics perfectly matched the corresponding values reported in the watershed_results_ndr.gpkg shapefile from the model output. The version I used was InVEST 3.16.1 . So, please check the unit.
Thank you, @Eshetu , I think we are actually in agreement. In order to calculate the totals per watershed, the model sums the per-hectare value from all the pixels in the watershed using zonal stats. Then we apply a conversion to that sum so that it ends up in kg/yr. This sounds like the same conversion you did in order to get the matching zonal stats results. However, in our case we do this conversion in memory and the raster files themselves still contain values in units of kg/ha/yr.
Here is the relevant source code. This is the only place in the code where any pixel-area conversions are applied, and it only applies to the final calculations of the watershed sums, after performing the zonal stats. pixel_area has units of square meters.
@dave Thank you very much !!!
@Taherunnesa , @Eshetu , as far as the method for calculating retention. Please see this related thread: Using NDR outputs to map nutrient trapping - #2 by jesseG
@dave thank you so much for sharing this related thread.