pygmi.clust.super_class#
Supervised Classification tool.
Classes#
Graph map widget. |
|
Polygon Interactor for the supervised classification tool. |
|
Main supervised classification GUI. |
Functions#
|
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 (parent, optional) – Reference to the parent routine. The default is None.
- polyint(dat)#
Polygon integrator.
- Return type:
None.
- compute_initial_figure(dat)#
Compute initial figure.
- Parameters:
dat (dict) – PyGMI dataset/s (pygmi.raster.datatypes.Data) in a dictionary.
- Return type:
None.
- update_plot(dat)#
Update plot.
- Parameters:
dat (dict) – PyGMI dataset/s (pygmi.raster.datatypes.Data) in a dictionary.
- Return type:
None.
- class pygmi.clust.super_class.PolygonInteractor(axtmp, pntxy)#
Bases:
PyQt6.QtCore.QObject
Polygon Interactor for the supervised classification tool.
- Parameters:
axtmp (matplotlib.axes._axes.Axes) – Matplotlib axis.
pntxy (numpy array) – 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.pyqtSignal
- draw_callback(event=None)#
Draw callback.
- Parameters:
event (matplotlib.backend_bases.DrawEvent, optional) – Draw event object. The default is None.
- Return type:
None.
- new_poly(npoly=None)#
Create new polygon.
- Parameters:
npoly (list or None, optional) – New polygon coordinates.
- Return type:
None.
- 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:
ind – 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.
- Return type:
None.
- button_release_callback(event)#
Button release callback.
- Parameters:
event (matplotlib.backend_bases.MouseEvent) – Mouse Event.
- Return type:
None.
- update_plots()#
Update plots.
- Return type:
None.
- motion_notify_callback(event)#
Motion notify on mouse movement.
- Parameters:
event (matplotlib.backend_bases.MouseEvent) – Mouse event.
- Return type:
None.
- class pygmi.clust.super_class.SuperClass(parent=None)#
Bases:
pygmi.misc.BasicModule
Main supervised classification GUI.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- setupui()#
Set up UI.
- Return type:
None.
- class_change()#
Routine called when current classification choice changes.
- Return type:
None.
- calc_metrics()#
Calculate metrics.
- Return type:
None.
- updatepoly(xycoords=None)#
Update polygon.
- Parameters:
xycoords (numpy array, optional) – x, y coordinates. The default is None.
- Return type:
None.
- oncellchange(row, col)#
Routine activated whenever a cell is changed.
- Parameters:
row (int) – Current row.
col (int) – Current column.
- Return type:
None.
- onrowchange(current, previous)#
Routine activated whenever a row is changed.
- Parameters:
current (QTableWidgetItem) – current item.
previous (QTableWidgetItem) – previous item.
- Return type:
None.
- on_apoly()#
On add polygon.
- Return type:
None.
- on_dpoly()#
On delete polygon.
- Return type:
None.
- on_combo()#
On combo to choose type of plot for data.
- Return type:
None.
- 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, optional) – Run settings without a dialog. The default is False.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- saveproj()#
Save project data from class.
- Return type:
None.
- 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 array) – Point.
s0 (numpy array) – Start of segment.
s1 (numpy array) – End of segment.
- Returns:
Distance of point to segment.
- Return type:
numpy array