lissage module

Lissage v0.1

class lissage.RunBuider

Produces all possible combinations using the user-defined values, and forms a single execution of the program for each of these combinations. Saves outputs in script’s directory path.

static get_runs(params)

Produces all possible combinations using the user-defined values.

Parameters:params (OrderedDict) – Dictionary with all parameters & their possible arguments.
Returns:Contains all run combinations. List of named tuples.
Return type:list
static save_outputs(report, vectoutput, rastoutput, run, basepath='')

Saves results (.png, .shp, .kml, .json, .tiff) in directory.

Parameters:
  • report (dictionary) – Contains informations about the current execution of the program.
  • ( (rastoutput) – obj): Object of the VectorOutput() class.
  • ( – obj): Object of the RasterOutput() class.
  • run (namedtuple) – All input parameters from config file parser.
class lissage.Utils

Contains some usefull tools for the process.

static _determineStep(dataset, step=None)

Determine the step-value. Step is used to compute grid-nodes or traject-nodes when output is vector. Also, is used to compute pixel-size when output is raster.

Parameters:
  • ( (dataset) – obj): Object of the ReadData() class.
  • step (float, optional) – Value in meters. Defaults to None.
Returns:

Value in meters.

Return type:

float

static _set_filename(report, run, basepath='')

Create ‘Lissage_Results’ directory, create custom filename for each run & return output fullpath.

Parameters:
  • report (dictionary) – Contains informations about the current execution of the program.
  • run (namedtuple) – All input parameters from config file parser.
Returns:

Output fullpath filename

Return type:

str

static run_report(dataset, methodParams, vectoutput)

Convert dataset extent back to geographic crs, if it’s nessecary. Create a metadata report.json file, containing information about executed ‘Run’, which will be saved in ‘Lissage_Results’ directory.

Parameters:
  • ( (vectoutput) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
  • ( – obj): Object of the VectorOutput() class.
Returns:

Information about executed ‘Run’.

Return type:

dictionary

class lissage.ReadData(inPath, input_crs=None)
__init__(inPath, input_crs=None)

Reads input data & computes usefull variables, like weights based on equation (2). Keeps one direction for every azimuth by a simple rule of smallest angle. Also keeps columns of data as array class-attributes.

Computes extent (dict) which are the maximum & minimun coordinates for every axis (x,y), w (array) which are the weights computed based on equation (2) and range between 0-1 and azimed (float) which is the azimuth average from the whole area.

Parameters:
  • inPath (str) – Fullpath of input data file.
  • input_crs (int, optional) – Input data SRID. Defaults to None.
_aziAverage()

Find average azimuth based on Lee and Angelier (1993).

_extent()

Region extent. Coordinates should be projected, for further calculations.

_identifyFields(df, input_crs)

Reads input-data column-names.

Also, checks if input ‘df’ is a pandas geodataframe or a simple pandas dataframe, and if a geometry column is available, returns only two fields: ‘azimuth’ & ‘angular-error’. Else, if geometry column is unavailable, returns four fields: ‘azimuth’, ‘angular-error’, ‘x’ and ‘y’. This is because, if a geometry column is available, coordinates will be sourced from geometry field and not directly from ‘x’ and ‘y’ fields.

If input-data is a flatfile, is implied that there is no CRS metadata. And, if also there is not a user-input SRID, this function assumes that input-data CRS is WGS‘84 and checks the flatfile’s columnames to determine a projected (3857) or a geographic (4326) SRID.

Parameters:
  • df (pandas dataframe, geodataframe) – Input data.
  • input_crs (int) – Input data SRID.
Returns:

Tuple of strings containing lon or x field name, lat or y field name, azimuth field name

and azimuth’s angular error field name.

Return type:

tuple

_oneDirection(azi)

Keep one of the two directions. Return values in range [0, 180] degrees.

Parameters:azi (ndarray) – Azimuth value.
Returns:[description]
Return type:ndarray
_readData(input_crs)

Reads data as geodataframe, w.r.t. file format. Manages CRS and necessary transformations. Sets usefull data-fields as object attributes.

For azimuths, checks values and keeps only one dimension (smaller angle rule). Also, computes the weight of every measurement w.r.t. angular errors. If anglar errors are not available, considers them all as zero values.

Parameters:input_crs (int) – Input data SRID.
_weight(th)

Returns computed weights w.r.t angular error. Equation 2.

Parameters:th (ndarray) – Azimuth angular error.
Returns:Azimuth angular error.
Return type:ndarray
class lissage.MethodParams(dataset, runmode, order, opt)
__init__(dataset, runmode, order, opt)

Compute method-parameters for selected method, based on Lee and Angelier (1993). Sets computed method-parameters as class-attributes. If ‘polynomial’ method is selected, order of polynomial function is computed or taken as user-input. If ‘weighted’ method is selected, radius for weighting distance & order for weighting distance are computed, or accepts them as user-input.

Computes k (int) which is the order of polynomial function. Or p (int) which is the radius for weighting distance and R (int) which is the power order for weighting distance.

Parameters:
  • ( (dataset) – obj): Object of the ReadData() class.
  • runmode (int) – Method selection, two options available (1: polynomial or 2: distance weighting).
  • order (int) – Order of smoothing, three options available: (0:global, 1, 2:local).
  • opt (int) – Way of setting method parameters, depending on selected method. Two options available (0:auto or 1:manual). If ‘auto’ is selected, method parameters are computed based on Lee and Angelier (1993).
_methodParameters(dataset)

Compute method parameters, depending on selected method.

Parameters:( (dataset) – obj): Object of the ReadData() class.
class lissage.Execute(point, dataset, methodParams)
__init__(point, dataset, methodParams)

Execute polynom (Equation 1) or weighted method (Equation 5) depending selection.

Parameters:
  • point (tuple) – (xi, yi) coordinates of random point for which Q is computed.
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
_polynom(point, dataset, methodParams)

The main function of polynominal equations (Equation 1). Compute azimuth for given point. Polynom until 3th degree.

Parameters:
  • point (tuple) – (xi, yi) coordinates of random point for which Q is computed.
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
Returns:

Azimuth for given point.

Return type:

float

_weighted(point, dataset, methodParams)

The main function of weighted distance method (Equation 5). Compute azimuth for given point w.r.t. radius & power order for distance-related weights (Equation 4).

Parameters:
  • point (tuple) – (xi, yi) coordinates of random point for which Q is computed.
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
Returns:

Azimuth for given point.

Return type:

float

class lissage.VectorOutput(dataset, methodParams, outmode, step=None)
__init__(dataset, methodParams, outmode, step=None)

Computes nodes and corresponding azimuth values for grid or trajcetories. Creates corresponding geometries and sets all the above as a geodataframe class-attribute. Final result is a geo-dataframe. In case of grid, ‘result’ contains point geometries and corresponding azimuth values. In case of trajectories, ‘result’ contains line geometries and corresponding id value for every trajectory.

Parameters:
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
  • outmode (int) – Way of output. Two options available (1: grid or 2: trajectories).
  • step (float, optional) – Value in meters. Defaults to None.
_compute_grid_nodes(dataset, methodParams)

Outputs points and their azimuth value.

Parameters:
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
_compute_traj_nodes(dataset, methodParams)

Compute nodes on trajectories for every traj, starting from main line.

Parameters:
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
_main_traj_nodes(dataset)

Computes nodes on line which is perpendicular to average azimuth. This is the main line on which trajectories will be designed.

Parameters:( (dataset) – obj): Object of the ReadData() class.
Returns:List of tuples containing x, y coordinates of main line nodes.
Return type:list
class lissage.RasterOutput(dataset, methodParams, step=None)
__init__(dataset, methodParams, step=None)

Compute azimuth value for every pixel of a raster file. Resolution of raster is determined using step-value.

Parameters:
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
  • step (float, optional) – Value in meters. Defaults to None.
_compute_pixel_values(dataset, methodParams, step)

Produce raster output.

Parameters:
  • ( (methodParams) – obj): Object of the ReadData() class.
  • ( – obj): Object of the MethodParams() class. User-defined or internally computed values for the corresponding method parameters.
  • step (float) – Value in meters.
Returns:

result (2d array), Image array with azimuth value in every pixel, determined using Execute class.

metedata (dict), Image metadata, uselfull to save georeferenced image.

Return type:

tuple