Nutrient Package¶

Model Entry Point¶

invest_natcap.nutrient.nutrient.execute(args)

A high level wrapper for the InVEST nutrient model that first calls through to the InVEST water yield function. This is a historical separation that used to make sense when we manually required users to pass the water yield pixel raster to the nutrient output.

Parameters: workspace_dir (string) – directory in which the output and intermediate files will be saved results_suffix (string) – This text will be appended to the end of the output files to help separate multiple runs. dem_uri (string) – A GIS raster dataset with an elevation value for each cell. precipitation_uri (string) – A GIS raster dataset with a non-zero value for average annual precipitation for each cell. eto_uri (string) – A GIS raster dataset, with an annual average evapotranspiration value for each cell. depth_to_root_rest_layer_uri (string) – GIS raster dataset with an average root restricting layer depth value for each cell. pawc_uri (string) – A GIS raster dataset with a plant available water content value for each cell. lulc_uri (string) – A GIS raster dataset, with an integer LULC code for each cell. seasonality_constant (float) – Floating point value on the order of 1 to 20 corresponding to the seasonal distribution of precipitation watersheds_uri (string) – This is a layer of watersheds such that each watershed contributes to a point of interest where water quality will be analyzed. biophysical_table_uri (string) – A table containing model information corresponding to each of the land use classes in the LULC raster input. calc_p (boolean) – Select to calculate phosphorous export. calc_n (boolean) – Select to calculate nitrogen export. accum_threshold (int) – The number of upstream cells that must flow into a cell before it’s considered part of a stream such that retention stops and the remaining export is exported to the stream. water_purification_threshold_table_uri (string) – A table containing annual nutrient load threshold information. valuation_enabled (boolean) – indicates whether the model will include valuation water_purification_valuation_table_uri (string) – A table containing valuation information

Example Args Dictionary:

{
'workspace_dir': 'path/to/workspace_dir',
'results_suffix': '_results',
'dem_uri': 'path/to/',
'precipitation_uri': 'path/to/raster',
'eto_uri': 'path/to/raster',
'depth_to_root_rest_layer_uri': 'path/to/raster',
'pawc_uri': 'path/to/raster',
'lulc_uri': 'path/to/raster',
'seasonality_constant': 5,
'watersheds_uri': 'path/to/shapefile',
'biophysical_table_uri': 'path/to/csv',
'calc_p': True,
'calc_n': True,
'accum_threshold': 1000,
'water_purification_threshold_table_uri': 'path/to/csv',
'valuation_enabled': True,
'water_purification_valuation_table_uri': 'path/to/csv',

}


Nutrient¶

Module for the execution of the biophysical component of the InVEST Nutrient Retention model.

invest_natcap.nutrient.nutrient.add_fields_to_shapefile(key_field, field_summaries, output_layer, field_header_order=None)

Adds fields and their values indexed by key fields to an OGR layer open for writing.

key_field - name of the key field in the output_layer that
uniquely identifies each polygon.
field_summaries - a dictionary indexed by the desired field
name to place in the polygon that indexes to another dictionary indexed by key_field value to map to that particular polygon. ex {‘field_name_1’: {key_val1: value, key_val2: value}, ‘field_name_2’: {key_val1: value, etc.

output_layer - an open writable OGR layer field_header_order - a list of field headers in the order we

wish them to appear in the output table, if None then random key order in field summaries is used.

returns nothing

invest_natcap.nutrient.nutrient.disc(years, percent_rate)

Calculate discount rate for a given number of years

years - an integer number of years percent_rate - a discount rate in percent

returns the discount rate for the number of years to use in
a calculation like yearly_cost * disc(years, percent_rate)
invest_natcap.nutrient.nutrient.execute(args)

A high level wrapper for the InVEST nutrient model that first calls through to the InVEST water yield function. This is a historical separation that used to make sense when we manually required users to pass the water yield pixel raster to the nutrient output.

Parameters: workspace_dir (string) – directory in which the output and intermediate files will be saved results_suffix (string) – This text will be appended to the end of the output files to help separate multiple runs. dem_uri (string) – A GIS raster dataset with an elevation value for each cell. precipitation_uri (string) – A GIS raster dataset with a non-zero value for average annual precipitation for each cell. eto_uri (string) – A GIS raster dataset, with an annual average evapotranspiration value for each cell. depth_to_root_rest_layer_uri (string) – GIS raster dataset with an average root restricting layer depth value for each cell. pawc_uri (string) – A GIS raster dataset with a plant available water content value for each cell. lulc_uri (string) – A GIS raster dataset, with an integer LULC code for each cell. seasonality_constant (float) – Floating point value on the order of 1 to 20 corresponding to the seasonal distribution of precipitation watersheds_uri (string) – This is a layer of watersheds such that each watershed contributes to a point of interest where water quality will be analyzed. biophysical_table_uri (string) – A table containing model information corresponding to each of the land use classes in the LULC raster input. calc_p (boolean) – Select to calculate phosphorous export. calc_n (boolean) – Select to calculate nitrogen export. accum_threshold (int) – The number of upstream cells that must flow into a cell before it’s considered part of a stream such that retention stops and the remaining export is exported to the stream. water_purification_threshold_table_uri (string) – A table containing annual nutrient load threshold information. valuation_enabled (boolean) – indicates whether the model will include valuation water_purification_valuation_table_uri (string) – A table containing valuation information

Example Args Dictionary:

{
'workspace_dir': 'path/to/workspace_dir',
'results_suffix': '_results',
'dem_uri': 'path/to/',
'precipitation_uri': 'path/to/raster',
'eto_uri': 'path/to/raster',
'depth_to_root_rest_layer_uri': 'path/to/raster',
'pawc_uri': 'path/to/raster',
'lulc_uri': 'path/to/raster',
'seasonality_constant': 5,
'watersheds_uri': 'path/to/shapefile',
'biophysical_table_uri': 'path/to/csv',
'calc_p': True,
'calc_n': True,
'accum_threshold': 1000,
'water_purification_threshold_table_uri': 'path/to/csv',
'valuation_enabled': True,
'water_purification_valuation_table_uri': 'path/to/csv',

}