pygmi.clust.super_class#

Supervised Classification tool.

Classes#

GraphMap

Graph map widget.

PolygonInteractor

Polygon Interactor for the supervised classification tool.

SuperClass

Main supervised classification GUI.

Functions#

dist_point_to_segment(p, s0, s1)

Dist point to segment.

Module Contents#

class pygmi.clust.super_class.GraphMap(parent=None)#

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

Graph map widget.

Parameters:

parent – Reference to the parent routine. The default is None.

polyint(dat)#

Polygon integrator.

Parameters:

dat (dict) – PyGMI dataset/s (pygmi.raster.datatypes.Data) in a dictionary.

compute_initial_figure(dat)#

Compute initial figure.

Parameters:

dat (dict) – PyGMI dataset/s (pygmi.raster.datatypes.Data) in a dictionary.

update_plot(dat)#

Update plot.

Parameters:

dat (dict) – PyGMI dataset/s (pygmi.raster.datatypes.Data) in a dictionary.

update_class(dat)#

Update plot.

Parameters:

dat (numpy.ma.MaskedArray) – PyGMI dataset in a masked array.

class pygmi.clust.super_class.PolygonInteractor(axtmp, pntxy)#

Bases: PySide6.QtCore.QObject

Polygon Interactor for the supervised classification tool.

Parameters:
  • axtmp (matplotlib.axes.Axes) – Matplotlib axis.

  • pntxy (numpy.typing.NDArray) – X and Y mouse coordinates in N by 2 array.

epsilon#

Epsilon tolerance for index detection.

Type:

int

polyi_changed#

Qt signal when polygon has changed.

Type:

QtCore.Signal

draw_callback(event=None)#

Draw callback.

Parameters:

event (matplotlib.backend_bases.DrawEvent | None) – Draw event object. The default is None.

new_poly(npoly=None)#

Create new polygon.

Parameters:

npoly (list | None) – New polygon coordinates.

get_ind_under_point(event)#

Get the index of vertex under point if within epsilon tolerance.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse event.

Returns:

Index of vertex under point.

Return type:

int or None

button_press_callback(event)#

Button press callback.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse event.

button_release_callback(event)#

Button release callback.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse Event.

update_plots()#

Update plots.

motion_notify_callback(event)#

Motion notify on mouse movement.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse event.

class pygmi.clust.super_class.SuperClass(parent=None)#

Bases: pygmi.misc.BasicModule

Main supervised classification GUI.

Parameters:

parent – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

calculate()#

Calculate new clusters.

class_change()#

Routine called when current classification choice changes.

calc_metrics()#

Calculate metrics.

updatepoly(xycoords=None)#

Update polygon.

Parameters:

xycoords (numpy.typing.NDArray | None) – x, y coordinates. The default is None.

oncellchange(row, col)#

Routine activated whenever a cell is changed.

Parameters:
  • row (int) – Current row.

  • col (int) – Current column.

onrowchange(current, previous)#

Routine activated whenever a row is changed.

Parameters:
  • current (PySide6.QtWidgets.QTableWidgetItem) – current table item.

  • previous (PySide6.QtWidgets.QTableWidgetItem) – previous table item.

on_apoly()#

On add polygon.

on_dpoly()#

On delete polygon.

on_combo()#

On combo to choose type of plot for data.

on_radio()#

On radiobutton to choose type of plot for data.

load_shape()#

Load shapefile.

Returns:

True if successful, False otherwise.

Return type:

bool

save_shape()#

Save shapefile.

Returns:

True if successful, False otherwise.

Return type:

bool

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

init_classifier()#

Initialise classifier.

Returns:

  • classifier (object) – Scikit learn classification object.

  • lbls (numpy array) – Class labels.

  • datall (numpy array) – Dataset.

  • X_test (numpy array) – X test dataset.

  • y_test (numpy array) – Y test dataset.

  • tlbls (numpy array) – Class labels.

update_class_polys()#

Update class poly summaries.

pygmi.clust.super_class.dist_point_to_segment(p, s0, s1)#

Dist point to segment.

Reimplementation of Matplotlib’s dist_point_to_segment, after it was depreciated. Follows http://geomalgorithms.com/a02-_lines.html

Parameters:
  • p (numpy.typing.NDArray) – Point.

  • s0 (numpy.typing.NDArray) – Start of segment.

  • s1 (numpy.typing.NDArray) – End of segment.

Returns:

Distance of point to segment.

Return type:

ndarray