natcap.invest.crop_production_regression¶
InVEST Crop Production Percentile Model.
-
natcap.invest.crop_production_regression.
aggregate_regression_results_to_polygons
(base_aggregate_vector_path, target_aggregate_vector_path, landcover_raster_projection, crop_to_landcover_table, nutrient_table, output_dir, file_suffix, target_aggregate_table_path)¶ Write table with aggregate results of yield and nutrient values.
Use zonal statistics to summarize total observed and interpolated production and nutrient information for each polygon in base_aggregate_vector_path.
- Parameters
base_aggregate_vector_path (string) – path to polygon vector
target_aggregate_vector_path (string) – path to re-projected copy of polygon vector
landcover_raster_projection (string) – a WKT projection string
crop_to_landcover_table (dict) – landcover codes keyed by crop names
nutrient_table (dict) – a lookup of nutrient values by crop in the form of nutrient_table[<crop>][<nutrient>].
output_dir (string) – the file path to the output workspace.
file_suffix (string) – string to append to any output filenames.
target_aggregate_table_path (string) – path to ‘aggregate_results.csv’ in the output workspace
- Returns
None
-
natcap.invest.crop_production_regression.
execute
(args)¶ Crop Production Regression.
This model will take a landcover (crop cover?), N, P, and K map and produce modeled yields, and a nutrient table.
- Parameters
args['workspace_dir'] (string) – output directory for intermediate, temporary, and final files
args['results_suffix'] (string) – (optional) string to append to any output file names
args['landcover_raster_path'] (string) – path to landcover raster
args['landcover_to_crop_table_path'] (string) –
path to a table that converts landcover types to crop names that has two headers:
lucode: integer value corresponding to a landcover code in args[‘landcover_raster_path’].
crop_name: a string that must match one of the crops in args[‘model_data_path’]/climate_regression_yield_tables/[cropname]_* A ValueError is raised if strings don’t match.
args['fertilization_rate_table_path'] (string) – path to CSV table that contains fertilization rates for the crops in the simulation, though it can contain additional crops not used in the simulation. The headers must be ‘crop_name’, ‘nitrogen_rate’, ‘phosphorus_rate’, and ‘potassium_rate’, where ‘crop_name’ is the name string used to identify crops in the ‘landcover_to_crop_table_path’, and rates are in units kg/Ha.
args['aggregate_polygon_path'] (string) – path to polygon vector that will be used to aggregate crop yields and total nutrient value. (optional, if value is None, then skipped)
args['model_data_path'] (string) –
path to the InVEST Crop Production global data directory. This model expects that the following directories are subdirectories of this path:
climate_bin_maps (contains [cropname]_climate_bin.tif files)
climate_percentile_yield (contains [cropname]_percentile_yield_table.csv files)
Please see the InVEST user’s guide chapter on crop production for details about how to download these data.
- Returns
None.
-
natcap.invest.crop_production_regression.
tabulate_regression_results
(nutrient_table, crop_to_landcover_table, pixel_area_ha, landcover_raster_path, landcover_nodata, output_dir, file_suffix, target_table_path)¶ Write table with total yield and nutrient results by crop.
This function includes all the operations that write to results_table.csv.
- Parameters
nutrient_table (dict) – a lookup of nutrient values by crop in the form of nutrient_table[<crop>][<nutrient>].
crop_to_landcover_table (dict) – landcover codes keyed by crop names
pixel_area_ha (float) – area of lulc raster cells (hectares)
landcover_raster_path (string) – path to landcover raster
landcover_nodata (float) – landcover raster nodata value
output_dir (string) – the file path to the output workspace.
file_suffix (string) – string to append to any output filenames.
target_table_path (string) – path to ‘result_table.csv’ in the output workspace
- Returns
None