This page contains the documentation for the InaSAFE is_safe_interface module.
InaSAFE Disaster risk assessment tool developed by AusAid - IS Safe Interface.
The purpose of the module is to centralise interactions between the gui package and the underlying InaSAFE packages. This should be the only place where SAFE modules are imported directly.
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.
Query the inasafe engine to see what plugins are available.
Args:
theKeywordList - an optional parameter which should contain a list of 2 dictionaries (the number of items in the list is not enforced). The dictionaries should be obtained by using readKeywordsFromFile e.g.:
myFile1 = foo.shp myFile2 = bar.asc myKeywords1 = readKeywordsFromFile(myFile1) myKeywords2 = readKeywordsFromFile(myFile2) myList = [myKeywords1, myKeywords2] myFunctions = availableFunctions(myList)
A dictionary of strings where each is a plugin name.
Note
If theKeywordList is not provided, all available plugins will be returned in the list.
Thin wrapper around the safe calculate_impact function.
Grow bounding box with one unit of resolution in each direction.
Args:
- theGeoExtent - Bounding box with format [W, S, E, N]
- theCellSize - (resx, resy) Raster resolution in each direction.
If resolution is None bbox is returned unchanged.
Raises:
Any exceptions are propogated
Thin wrapper around the safe get_function_title.
A helper function to determine what the optimal extent is. Optimal extent should be considered as the intersection between the three inputs. The inasafe library will perform various checks to ensure that the extent is tenable, includes data from both etc.
This is just a thin wrapper around safe_api.bbox_intersection.
Typically the result of this function will be used to clip input layers to a commone extent before processing.
Args:
- theHazardGeoExtent - an array representing the hazard layer
extents in the form [xmin, ymin, xmax, ymax]. It is assumed that the coordinates are in EPSG:4326 although currently no checks are made to enforce this.
- theExposureGeoExtent - an array representing the exposure layer
extents in the form [xmin, ymin, xmax, ymax]. It is assumed that the coordinates are in EPSG:4326 although currently no checks are made to enforce this.
- theViewPortGeoExtent - an array representing the viewport
extents in the form [xmin, ymin, xmax, ymax]. It is assumed that the coordinates are in EPSG:4326 although currently no checks are made to enforce this.
- ..note:: We do minimal checking as the inasafe library takes
- care of it for us.
An array containing an extent in the form [xmin, ymin, xmax, ymax] e.g.:
[100.03, -1.14, 100.81, -0.73]
Thin wrapper around the safe impact_functions function.
Get styleinfo associated with a layer.
Args:
- theLayer - InaSAFE layer (raster or vector)
Raises:
- StyleInfoNotFoundException if the style is not found.
- InvalidParameterException if the paramers are not correct.
Get metadata from the keywords file associated with a local file in the file system.
Note
Requires a str representing a file path instance as parameter As opposed to readKeywordsFromLayer which takes a inasafe file object as parameter.
See also
readKeywordsFromLayer
Args:
- theLayerPath - a string representing a path to a layer
(e.g. ‘/tmp/foo.shp’, ‘/tmp/foo.tif’)
theKeyword - optional - the metadata keyword to retrieve e.g. ‘title’
Get metadata from the keywords file associated with a layer.
Note
Requires a inasafe layer instance as parameter.
See also
getKeywordFromPath
Args:
- theLayer - a InaSAFE layer (vector or raster)
- keyword - the metadata keyword to retrieve e.g. ‘title’
Thin wrapper around the safe read_layer function.
We define a tr() alias here since the is_safe_interface implementation below is not a class and does not inherit from QObject.
Note
This is just a thin wrapper around safe_api.verify.
Thin wrapper around the safe write_keywords function.