Prediction
Classes to perform multidiversity index prediction.
BaseDataManager
¶
Base class for data management. Contain layers to extract features needed for computation.
compute()
abstractmethod
¶
Compute sample from data layer and output a set of variables as Sample.
Source code in niva/core/prediction/data_manager.py
25 26 27 28 |
|
filter_iacs(layer)
¶
Filter IACS on Niva.ID fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer
|
qgis.core.QgsVectorLayer
|
IACS layer. |
required |
Returns:
Type | Description |
---|---|
qgis.core.QgsVectorLayer
|
Filtered IACS. |
Source code in niva/core/prediction/data_manager.py
30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
GridDataManager()
dataclass
¶
Bases: niva.core.prediction.data_manager.BaseDataManager
DataManager for grid based predictor.
compute(cell)
abstractmethod
¶
Compute a sample from cell geometry selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell
|
qgis.core.QgsGeometry
|
Cell to compute metrics on. |
required |
Returns:
Type | Description |
---|---|
niva.core.sample.Sample
|
Sample of variables. |
Source code in niva/core/prediction/data_manager.py
49 50 51 52 53 54 55 56 57 58 59 |
|
crop_feat(feature, geometry)
¶
Crop a feat with intersection geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature
|
qgis.core.QgsFeature
|
Fetaure to crop. |
required |
geometry
|
qgis.core.QgsGeometry
|
Geometry to compute intersection. |
required |
Returns:
Type | Description |
---|---|
typing.List[qgis.core.QgsFeature]
|
Cropped feature. |
Source code in niva/core/prediction/data_manager.py
61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_features(layer, index, cell, crop=True)
¶
Gather all features from a layer that intersect a geometry/cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer
|
qgis.core.QgsVectorLayer
|
Layer to gather features from. |
required |
cell
|
qgis.core.QgsGeometry
|
Geometry to gather feats. |
required |
crop
|
bool, **optional**
|
If True, crop feats to geometry. Defaults to False. |
True
|
Returns:
Type | Description |
---|---|
typing.List[qgis.core.QgsFeature]
|
List of geometries extracted. |
Source code in niva/core/prediction/data_manager.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
T1GridDataManager(*, iacs, artificial, naa=None)
dataclass
¶
Bases: niva.core.prediction.data_manager.GridDataManager
Data manager for Contra Tier 1 with grid based predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iacs
|
qgis.core.QgsVectorLayer
|
Layer of IACS data. Warning: Provide IACS with Niva.ID field. |
required |
artificial
|
qgis.core.QgsVectorLayer
|
Layer of artificial data. |
required |
naa
|
qgis.core.QgsVectorLayer
|
Layer of NAA data. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
iacs |
qgis.core.QgsVectorLayer
|
Layer of IACS data. |
artificial |
qgis.core.QgsVectorLayer
|
Layer of artificial data. |
naa |
Union[qgis.core.QgsVectorLayer, None]
|
Layer of NAA data or None if not passed to constructor. |
iacs_index |
qgis.core.QgsSpatialIndex
|
Spatial index for layer iacs. |
artificial_index |
qgis.core.QgsSpatialIndex
|
Spatial index for layer artificial. |
naa_index |
qgis.core.QgsSpatialIndex
|
Spatial index for layer naa. |
compute(cell)
¶
Compute metrics and build sample for cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell
|
qgis.core.QgsGeometry
|
Cell geometry to compute metric on. |
required |
Returns:
Type | Description |
---|---|
niva.core.sample.T1Sample
|
Tier 1 sample for cell. |
Source code in niva/core/prediction/data_manager.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
Predictor(context=QgsProcessingContext(), feedback=QgsProcessingFeedback(), *args, **kwargs)
¶
Bases: niva.core.mixins.QgsLogicMixin
Base predictor class.
Source code in niva/core/mixins.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
run()
abstractmethod
¶
Run the prediction and output a QgsVectorLayer with predictions.
Source code in niva/core/prediction/predictor.py
15 16 17 18 |
|
GridPredictor(tree, data_manager, grid, *args, **kwargs)
¶
Bases: niva.core.prediction.predictor.Predictor
Base predictor class for grid predictions.
Attributes:
Name | Type | Description |
---|---|---|
tree |
niva.core.contra.ContraTree
|
ContratTree for prediction. |
data_manager |
niva.core.prediction.data_manager.BaseDataManager
|
Data manager. |
grid |
qgis.core.QgsVectorLayer
|
Grdi to predict on. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree
|
niva.core.contra.ContraTree
|
ContratTree for prediction. |
required |
data_manager
|
niva.core.prediction.data_manager.BaseDataManager
|
Data manager. |
required |
grid
|
qgis.core.QgsVectorLayer
|
Grdi to predict on. |
required |
Source code in niva/core/prediction/predictor.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
run()
¶
Run the predictions by iterating over each grid cells.
Returns:
Type | Description |
---|---|
qgis.core.QgsVectorLayer
|
Prediction layer. |
Source code in niva/core/prediction/predictor.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
NivaMdi
¶
Base class for Niva's prediction.
predict_mdi()
abstractmethod
¶
Predict Niva MultiDiversityIndex.
Source code in niva/core/prediction/predictor.py
79 80 81 82 |
|
NivaMdiGridT1(grid, iacs, artificial, naa=None, tree_name='T1', *args, **kwargs)
¶
Bases: niva.core.prediction.predictor.NivaMdi
, niva.core.mixins.QgsLogicMixin
Manage Niva prediction for Tier 1 on a grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
qgis.core.QgsVectorLayer
|
Grid layer to predict on. |
required |
iacs
|
qgis.core.QgsVectorLayer
|
IACS layer with Niva.ID field. |
required |
artificial
|
qgis.core.QgsVectorLayer
|
Artificial layer. |
required |
naa
|
Union[QgsVectorLayer, None], **optional**
|
NAA layer. Defaults to None. |
None
|
tree_name
|
str, **optional**
|
Name of tree config into ContraTreeFactory. Defaults to "T1". |
'T1'
|
Attributes:
Name | Type | Description |
---|---|---|
tree |
niva.core.contra.ContraTree
|
Contra decision tree to use for prediction. |
data_manager |
niva.core.prediction.data_manager.T1GridDataManager
|
Data manager for grid T1. |
predictor |
niva.core.prediction.predictor.GridPredictor
|
Predictor to use for T1 grid prediction. |
Source code in niva/core/prediction/predictor.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
predict_mdi()
¶
Run prediction.
Returns:
Type | Description |
---|---|
qgis.core.QgsVectorLayer
|
Prediction layer. |
Source code in niva/core/prediction/predictor.py
120 121 122 123 124 125 126 |
|