natcap.invest.scenario_generator package

Submodules

natcap.invest.scenario_generator.scenario_generator module

Scenario Generator Module.

natcap.invest.scenario_generator.scenario_generator.calculate_distance_raster_uri(dataset_in_uri, dataset_out_uri)

Calculate distance to non-zero cell for all input zero-value cells.

Parameters:
  • dataset_in_uri (str) – the input mask raster. Distances calculated from the non-zero cells in raster.
  • dataset_out_uri (str) – the output raster where all zero values are equal to the euclidean distance of the closest non-zero pixel.
natcap.invest.scenario_generator.scenario_generator.calculate_priority(priority_table_uri)

Create dictionary mapping each land-cover class to their priority weight.

Parameters:priority_table_uri (str) – path to priority csv table
Returns:priority_dict – land-cover and weights_matrix
Return type:dict
natcap.invest.scenario_generator.scenario_generator.calculate_weights(array, rounding=4)

Create list of priority weights by land-cover class.

Parameters:
  • array (np.array) – input array
  • rounding (int) – number of decimal places to include
Returns:

weights_list – list of priority weights

Return type:

list

natcap.invest.scenario_generator.scenario_generator.execute(args)

Scenario Generator: Rule-Based.

Model entry-point.

Parameters:
  • workspace_dir (str) – path to workspace directory
  • suffix (str) – string to append to output files
  • landcover (str) – path to land-cover raster
  • transition (str) – path to land-cover attributes table
  • calculate_priorities (bool) – whether to calculate priorities
  • priorities_csv_uri (str) – path to priority csv table
  • calculate_proximity (bool) – whether to calculate proximity
  • proximity_weight (float) – weight given to proximity
  • calculate_transition (bool) – whether to specifiy transitions
  • calculate_factors (bool) – whether to use suitability factors
  • suitability_folder (str) – path to suitability folder
  • suitability (str) – path to suitability factors table
  • weight (float) – suitability factor weight
  • factor_inclusion (int) – the rasterization method – all touched or center points
  • factors_field_container (bool) – whether to use suitability factor inputs
  • calculate_constraints (bool) – whether to use constraint inputs
  • constraints (str) – filepath to constraints shapefile layer
  • constraints_field (str) – shapefile field containing constraints field
  • override_layer (bool) – whether to use override layer
  • override (str) – path to override shapefile
  • override_field (str) – shapefile field containing override value
  • override_inclusion (int) – the rasterization method

Example Args:

args = {
    'workspace_dir': 'path/to/dir',
    'suffix': '',
    'landcover': 'path/to/raster',
    'transition': 'path/to/csv',
    'calculate_priorities': True,
    'priorities_csv_uri': 'path/to/csv',
    'calculate_proximity': True,
    'calculate_transition': True,
    'calculate_factors': True,
    'suitability_folder': 'path/to/dir',
    'suitability': 'path/to/csv',
    'weight': 0.5,
    'factor_inclusion': 0,
    'factors_field_container': True,
    'calculate_constraints': True,
    'constraints': 'path/to/shapefile',
    'constraints_field': '',
    'override_layer': True,
    'override': 'path/to/shapefile',
    'override_field': '',
    'override_inclusion': 0
}

Added Afterwards:

d = {
    'proximity_weight': 0.3,
    'distance_field': '',
    'transition_id': 'ID',
    'percent_field': 'Percent Change',
    'area_field': 'Area Change',
    'priority_field': 'Priority',
    'proximity_field': 'Proximity',
    'suitability_id': '',
    'suitability_layer': '',
    'suitability_field': '',
}
natcap.invest.scenario_generator.scenario_generator.filter_fragments(input_uri, size, output_uri)

Filter fragments.

Parameters:
  • input_uri (str) – path to input raster
  • size (float) – patch (/fragments?) size threshold
  • output_uri (str) – path to output raster
natcap.invest.scenario_generator.scenario_generator.generate_chart_html(cover_dict, cover_names_dict, workspace_dir)

Create HTML page showing statistics about land-cover change.

  • Initial land-cover cell count
  • Scenario land-cover cell count
  • Land-cover percent change
  • Land-cover percent total: initial, final, change
  • Transition matrix
  • Unconverted pixels list
Parameters:
  • cover_dict (dict) – land cover {‘cover_id’: [before, after]}
  • cover_names_dict (dict) – land cover names {‘cover_id’: ‘cover_name’}
  • workspace_dir (str) – path to workspace directory
Returns:

chart_html – html chart

Return type:

str

natcap.invest.scenario_generator.scenario_generator.get_geometry_type_from_uri(datasource_uri)

Get geometry type from a shapefile.

Parameters:datasource_uri (str) – path to shapefile
Returns:shape_type – OGR geometry type
Return type:int
natcap.invest.scenario_generator.scenario_generator.get_transition_pairs_count_from_uri(dataset_uri_list)

Find transition summary statistics between lulc rasters.

Parameters:dataset_uri_list (list) – list of paths to rasters
Returns:unique_raster_values_count – cell type with each raster value transitions (dict): count of cells
Return type:dict

Module contents