safe.gui.tools.batch.scenario_runner module

InaSAFE Disaster risk assessment tool developed by AusAid -
Helper module for gui script functions.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

safe.gui.tools.batch.scenario_runner.add_layers(scenario_dir, paths, iface)[source]

Add the layers described in a scenario file to QGIS.

Parameters:
  • scenario_dir (str) – Base directory to find path.
  • paths (str, list) – Path of scenario file (or a list of paths).
  • iface (QgsInterface) – iface instance to do necessary things to QGIS.
Raises:

Exception, TypeError, FileNotFoundError

Note:
  • Exception - occurs when paths have illegal extension
  • TypeError - occurs when paths is not string or list
  • FileNotFoundError - occurs when file not found
safe.gui.tools.batch.scenario_runner.extract_path(scenario_file_path, path)[source]

Get a path and basename given a scenarioFilePath and path.

Parameters:
  • scenario_file_path (str) – Path to a scenario file.
  • path (str) –
Returns:

Tuple containing path and base name

Return type:

(str, str)

safe.gui.tools.batch.scenario_runner.get_map_canvas()[source]

Return map canvas object

safe.gui.tools.batch.scenario_runner.run_scenario(dock=None)[source]

Run the current scenario.

Parameters:dock – Dock instance
safe.gui.tools.batch.scenario_runner.set_aggregation_layer(aggregation_layer, dock=None)[source]

Set the aggregation combo to use the layer with the given name.

Parameters:
  • aggregation_layer – str - a string representing the source name of the desired aggregation layer.
  • dock – a dock instance
Returns bool:

True on success, False in the case that the aggregation layer is not in the aggregation selector.

Note

Probably won’t work for sublayers and anything else other than file based layers (e.g. shp).

safe.gui.tools.batch.scenario_runner.set_function_id(function_id, dock=None)[source]

Set the function combo to use the function with the given id.

Parameters:
  • function_id – str - a string representing the unique identifier for the desired function.
  • dock – a dock instance
Returns bool:

True on success, False in the case that the function is not present in the function selector (based on the context of loaded hazard and exposure layers.