Documentation#

class hedge_tools.hedgetools_app.HedgeToolsApp(
processing_path: str,
prefix_path: str = '/usr',
providers: List[qgis.core.QgsProcessingProvider] = [],
project: str | qgis.core.QgsProject = qgis.core.QgsProject.instance,
use_canvas: bool = False,
canvas_name: str = 'HedgeTools Map Viewer',
debug_mode: bool = False,
)[source]#

Bases : QgisApp, LoggerMixin

Provides access to the HedgeTools algorithms

Updates the links (pid, vid, eid, src_vid, tgt_vid) between polygon, arc and point layers.

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of Arc

  • node_layer (QgsVectorLayer) – Layer of Node

  • out_poly_path (Optional[str], optional) – Path for the output polygon layer if None it’ll create a memory layer, defaults to None

  • out_arc_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • out_node_path (Optional[str], optional) – Path for the output node layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Arc layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

manage_raster_tiles(
extent: qgis.core.QgsRectangle,
input_dir: str,
output_dir: str,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[None, None][source]#

This algorithm intersects a vector layer extent with the extent of all rasters within a directory, and copies them in an other directory if they intersect.

Paramètres:
  • extent (QgsRectangle) – Extent of your study area

  • input_dir (str, optional) – Directory containing the files, defaults to None

  • output_dir – Directory

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

Empty dict

Type renvoyé:

Dict[None, None]

generate_dhm(
dtm: qgis.core.QgsRasterLayer,
dsm: qgis.core.QgsRasterLayer,
dtm_band: int = 1,
dsm_band: int = 1,
threshold: float = 2.5,
extent: qgis.core.QgsRectangle | None = None,
extent_option: int = 0,
resampling: int = -1,
resolution: float | None = None,
output_path: str = 'TEMPORARY_OUTPUT',
output_mask: str = 'TEMPORARY_OUTPUT',
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsRasterLayer][source]#

Computes a DHM from a DTM and a DSM.

Paramètres:
  • dtm (QgsRasterLayer) – Digital Terrain Model raster

  • dsm (QgsRasterLayer) – Digital Surface Model raster

  • dtm_band (int) – Band of the dtm, GDAL numerotation, defaults to 1

  • dsm_band (int) – Band of the dsm, GDAL numerotation, defaults to 1

  • extent (Optional[QgsRectangle]) – Subset extent if provided, defaults to None

  • threshold (float, optional) – Threshold to binarize the dhm, defaults to 2.5

  • extent_option (Union[ExtentMethod, int]) –

    Handling of extent differences, defaults to 0

    • 0: Ignore - Will ignore CRS and only check both inputs dimensions. Raise an error if both inputs have different dimensions.

    • 1: Fail - Will check if both inputs are in the same CRS and have the same dimensions (Equality predicate). Raise an error otherwise.

    • 2: Union - Execute algorithm on the union of inputs.

    • 3: Intersect - Execute algorithm on the intersection of inputs. Raise an error if there is no intersection.

  • resampling (int, optional) –

    Resampling method for output resolution, defaults to -1

    • -1: None

    • 0: Nearest Neighbour

    • 1: Bilinear (2x2 Kernel)

    • 2: Cubic (4x4 Kernel)

    • 3: Cubic B-Spline (4x4 Kernel)

    • 4: Lanczos (6x6 Kernel)

    • 5: Average

    • 6: Mode

    • 7: Maximum

    • 8: Minimum

    • 9: Median

    • 10: First Quartile (Q1)

    • 11: Third Quartile (Q3)

  • resolution (Optional[float], optional) – Output resolution, defaults to None

  • output_path (str) – Path of the output mnh, defaults to « TEMPORARY_OUTPUT »

  • output_mask (str) – Path of the output mask, defaults to « TEMPORARY_OUTPUT »

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsRasterLayer as values, with keys being:

  • OUTPUT_DHM: DHM raster

  • OUTPUT_MASK: Binary mask of DHM raster

Type renvoyé:

Dict[str, QgsRasterLayer]

generate_ndvi(
red: qgis.core.QgsRasterLayer,
infrared: qgis.core.QgsRasterLayer,
red_band: int = 1,
infrared_band: int = 1,
extent: qgis.core.QgsRectangle | None = None,
threshold: float = 0.2,
compute_sieve: bool = True,
sieve_threshold: int = 100,
extent_option: int = 0,
resampling: int = -1,
resolution: float | None = None,
output_path: str = 'TEMPORARY_OUTPUT',
output_mask: str = 'TEMPORARY_OUTPUT',
output_sieve: str = 'TEMPORARY_OUTPUT',
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsRasterLayer][source]#

Computes NDVI from a raster with a red band and a raster with an infrared band.

Paramètres:
  • red (QgsRasterLayer) – Raster with a red band

  • infrared (QgsRasterLayer) – Raster with an infrared band

  • red_band (int) – Red band, GDAL numerotation, defaults to 1

  • infrared_band (int) – Infrared band, GDAL numerotation, defaults to 1

  • extent (Optional[QgsRectangle]) – Subset extent if provided, defaults to None

  • threshold (float, optional) – Threshold to binarize the ndvi, defaults to 0.2

  • compute_sieve (float, optional) – If true will sieve the mask it is strongly advised to avoid creating small features, defaults to True

  • sieve_threshold (float, optional) – Object size to delete in number of pixel, defaults to 100

  • extent_option (Union[ExtentMethod, int]) –

    Handling of extent differences, defaults to 0

    • 0: Ignore - Will ignore CRS and only check both inputs dimensions. Raise an error if both inputs have different dimensions.

    • 1: Fail - Will check if both inputs are in the same CRS and have the same dimensions (Equality predicate). Raise an error otherwise.

    • 2: Union - Execute algorithm on the union of inputs.

    • 3: Intersect - Execute algorithm on the intersection of inputs. Raise an error if there is no intersection.

  • resampling (int, optional) –

    Resampling method for output resolution, defaults to -1

    • -1: None

    • 0: Nearest Neighbour

    • 1: Bilinear (2x2 Kernel)

    • 2: Cubic (4x4 Kernel)

    • 3: Cubic B-Spline (4x4 Kernel)

    • 4: Lanczos (6x6 Kernel)

    • 5: Average

    • 6: Mode

    • 7: Maximum

    • 8: Minimum

    • 9: Median

    • 10: First Quartile (Q1)

    • 11: Third Quartile (Q3)

  • resolution (Optional[float], optional) – Output resolution, defaults to None

  • output_path (str) – Path of the output mnh, defaults to « TEMPORARY_OUTPUT »

  • output_mask (str) – Path of the output mask, defaults to « TEMPORARY_OUTPUT »

  • output_sieve (str) – Output path of the sieved mask, defaults to « TEMPORARY_OUTPUT »

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsRasterLayer as values, with keys being:

  • OUTPUT_NDVI: NDVI raster

  • OUTPUT_MASK: Binary mask of NDVI raster

  • OUTPUT_SIEVE: Sieved mask of NDVI, optional

Type renvoyé:

Dict[str, QgsRasterLayer]

generate_tree_cover(
dhm: qgis.core.QgsRasterLayer,
ndvi: qgis.core.QgsRasterLayer,
dhm_band: int = 1,
ndvi_band: int = 1,
extent: qgis.core.QgsRectangle | None = None,
compute_sieve: bool = True,
sieve_threshold: int = 100,
extent_option: int = 0,
resampling: int = -1,
resolution: float | None = None,
polygonize: bool = True,
output_path: str = 'TEMPORARY_OUTPUT',
output_sieve: str = 'TEMPORARY_OUTPUT',
output_vector: str = 'TEMPORARY_OUTPUT',
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsRasterLayer | qgis.core.QgsVectorLayer][source]#

Computes a tree cover raster and vector layer from a DHM and a NDVI raster

Paramètres:
  • dhm (QgsRasterLayer) – Digital Height Model raster

  • ndvi (QgsRasterLayer) – NDVI raster

  • dhm_band (int) – Band of the DHM, GDAL numerotation, defaults to 1

  • ndvi_band (int) – Band of the NDVI, GDAL numerotation, defaults to 1

  • extent (Optional[QgsRectangle]) – Subset extent if provided, defaults to None

  • compute_sieve (float, optional) – If true will sieve the mask it is strongly advised to avoid creating small features, defaults to True

  • sieve_threshold (float, optional) – Object size to delete in number of pixel, defaults to 100

  • extent_option (Union[ExtentMethod, int]) –

    Handling of extent differences, defaults to 0

    • 0: Ignore - Will ignore CRS and only check both inputs dimensions. Raise an error if both inputs have different dimensions.

    • 1: Fail - Will check if both inputs are in the same CRS and have the same dimensions (Equality predicate). Raise an error otherwise.

    • 2: Union - Execute algorithm on the union of inputs.

    • 3: Intersect - Execute algorithm on the intersection of inputs. Raise an error if there is no intersection.

  • resampling (int, optional) –

    Resampling method for output resolution, defaults to -1

    • -1: None

    • 0: Nearest Neighbour

    • 1: Bilinear (2x2 Kernel)

    • 2: Cubic (4x4 Kernel)

    • 3: Cubic B-Spline (4x4 Kernel)

    • 4: Lanczos (6x6 Kernel)

    • 5: Average

    • 6: Mode

    • 7: Maximum

    • 8: Minimum

    • 9: Median

    • 10: First Quartile (Q1)

    • 11: Third Quartile (Q3)

  • resolution (Optional[float], optional) – Output resolution, defaults to None

  • polygonize (Optional[float], optional) – If True will output a vector, defaults to True

  • output_path (str) – Path of the output mnh, defaults to « TEMPORARY_OUTPUT »

  • output_mask (st]) – Path of the output mask, defaults to « TEMPORARY_OUTPUT »

  • output_sieve (str) – Output path of the sieved mask, defaults to « TEMPORARY_OUTPUT »

  • output_vector (str) – Output path for the vector output, defaults to « TEMPORARY_OUTPUT »

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsRasterLayer/QgsVectorLayer as values, with keys being:

  • OUTPUT_TREE_COVER: tree cover raster

  • OUTPUT_SIEVE: Sieved tree cover, optional

  • OUTPUT_VECTOR: tree cover vector layer, optional

Type renvoyé:

Dict[str, Union[QgsRasterLayer, QgsVectorLayer]]

preprocess_cwa(
layer: qgis.core.QgsVectorLayer,
min_area: float = 20,
tolerance: float = 0.25,
hole_size: float = 50,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str = 'TEMPORARY_OUTPUT',
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

A preprocessing step is required before to categorize wooded area. It consists in:

  • eliminating small polygons with an area lower than the threshold

  • simplifying geometry with a Douglas-Peucker algorithm to smooth the vector borders obtained from a raster data

  • removing holes in polygons with an area lower than the threshold

  • correcting final geometry

Paramètres:
  • layer (QgsVectorLayer) – Layer to preprocess

  • min_area (float, optional) – Minimum area of geometries, defaults to 20

  • tolerance (float, optional) – Simplificaiton tolerance of the geometries, defaults to 0.25

  • hole_size (float, optional) – Minimum hole size in the geometries, defaults to 50

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of arc_layer, defaults to None

  • output_path (str) – Path of the output layer, defaults to TEMPORARY_OUTPUT

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

cwa(
layer: qgis.core.QgsVectorLayer,
opening: int = 20,
forest_area: int = 5000,
grove_area: int = 500,
request: qgis.core.QgsFeatureRequest | None = None,
output_forest_path: str = 'TEMPORARY_OUTPUT',
output_grove_path: str = 'TEMPORARY_OUTPUT',
output_hedge_path: str = 'TEMPORARY_OUTPUT',
output_tree_path: str = 'TEMPORARY_OUTPUT',
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

This algorithm classifies a tree cover layer into four categories: forest, grove, linear element, and scattered tree.

The buffer parameter is used to disconnect aggregated forests and linear element using an erosion-dilatation process. This parameter should be close to the maximum width of the linear element (hedgerows).

Thresholds related to forest and grove area are used to discriminate them based on their extent.

Paramètres:
  • layer (QgsVectorLayer) – Layer to categorize

  • openening (int, optional) – Morphological opening value to disconnect continuous elements, defaults to 20

  • forest_area (int, optional) – Minimum size of an element to be a forest, defaults to 5000

  • grove_area (int, optional) – Minimum size of an element to be a grove, defaults to 500

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of arc_layer, defaults to None

  • output_forest_path (str) – Path of the output forest layer, defaults to TEMPORARY_OUTPUT

  • output_grove_path (str) – Path of the output grove layer, defaults to TEMPORARY_OUTPUT

  • output_hedge_path (str) – Path of the output hedge layer, defaults to TEMPORARY_OUTPUT

  • output_tree_path (str) – Path of the output tree layer, defaults to TEMPORARY_OUTPUT

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • FOREST: Forest polygon layer

  • GROVE: Grove polygon layer

  • HEDGE: Hedge polygon layer

  • TREE: Tree polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

generate_tree_cover_from_lidar(
las: qgis.core.QgsPointCloudLayer,
category: List[float] = [4, 5],
extent: qgis.core.QgsRectangle | None = None,
compute_sieve: bool = True,
sieve_threshold: int = 100,
resolution: float | None = 1,
polygonize: bool = True,
output_path: str = 'TEMPORARY_OUTPUT',
output_sieve: str = 'TEMPORARY_OUTPUT',
output_vector: str = 'TEMPORARY_OUTPUT',
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsRasterLayer | qgis.core.QgsVectorLayer][source]#

Computes a tree cover raster from a point cloud layer by extracting vegetation points.

Paramètres:
  • las (QgsPointCloudLayer) – Classified point cloud layer

  • category (List[float])) – Vegetation category to keep. Accepted value are 3,4,5, defaults to [4,5]

  • extent (Optional[QgsRectangle]) – Subset extent if provided, defaults to None

  • compute_sieve (float, optional) – If true will sieve the mask it is strongly advised to avoid creating small features, defaults to True

  • sieve_threshold (float, optional) – Object size to delete in number of pixel, defaults to 100

  • resolution (Optional[float], optional) – Output resolution, defaults to 1

  • polygonize (Optional[float], optional) – If True will output a vector, defaults to True

  • output_path (str) – Path of the output mnh, defaults to « TEMPORARY_OUTPUT »

  • output_mask (st]) – Path of the output mask, defaults to « TEMPORARY_OUTPUT »

  • output_sieve (str) – Output path of the sieved mask, defaults to « TEMPORARY_OUTPUT »

  • output_vector (str) – Output path for the vector output, defaults to « TEMPORARY_OUTPUT »

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsRasterLayer/QgsVectorLayer as values, with keys being:

  • OUTPUT_TREE_COVER: tree cover raster

  • OUTPUT_SIEVE: Sieved tree cover, optional

  • OUTPUT_VECTOR: tree cover vector layer, optional

Type renvoyé:

Dict[str, Union[QgsRasterLayer, QgsVectorLayer]]

topological_arc(
poly_layer: qgis.core.QgsVectorLayer,
threshold: float = 30.0,
min_width: float = -1.0,
request: qgis.core.QgsFeatureRequest | None = None,
out_poly_path: str | None = None,
out_arc_path: str | None = None,
out_error_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes the median axis of polygons

The polygons will be exploded to single part if multiparts geometry is provided Each linestring will have an unique identifier « eid » and a link with his parent polygon with the field « pid ». The « pid » field in the polygon layer will be computed again.

The dangle length parameter defines the length threshold below which a dangle is removed. A dangle is a line segment that starts from a node with a degree of 3 or more and ends at a terminal node (an extremity).

The minimal width parameter is used to estimate the densification value applied internally. If too high, the median axis may become disconnected in narrow areas of the polygon. The default value of -1 allows to estimate automatically the minimal width but a minimal value of 2 is hard coded to prevent increasing too much the processing times. You can specify a value lower than 2 and different than -1 to override this safeguard.

An error layer will be created to output all disconnected arc form the main network. You can reconnect them manually. The unique identifier should already be handle.

The output polygon layer will have a boolean field is_hedge. If the value is False, it indicates that a complex line network (a network with many high degree nodes) has been detected within the polygon. This suggests that the feature may have been incorrectly classified as a hedge.

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • threshold (float, optional) – Dangle length threshold for pruning, defaults to 30.0

  • min_width (float, optional) – Minimal width used for densification, defaults to -1.0

  • tolerance (float, optional) – Dangle length (threshold) tolerance, defaults to 10.0 From threshold - tolerance to threshold width of the polygon will be measured. If the width is bigger than the width parameter value. The dangle will be kept.

  • width (float, option) – Width value used for advanced dangle length pruning, defaults to -1.0

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of arc_layer, defaults to None

  • output_poly_path (Optional[str], optional) – Path for the output polygon layer if None it’ll create a memory layer, defaults to None

  • output_arc_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • out_error_path (Optional[str], optional) – Path for the output error layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Arc layer

  • OUTPUT_ERROR: Error layer

Type renvoyé:

Dict[str, QgsVectorLayer]

topological_node(
arc_layer: qgis.core.QgsVectorLayer,
request: qgis.core.QgsFeatureRequest | None = None,
out_arc_path: str | None = None,
out_node_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes nodes of a median axis layer

Paramètres:
  • arc_layer (QgsVectorLayer) – Layer of linestring

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of arc_layer, defaults to None

  • out_arc_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • out_node_path (Optional[str], optional) – Path for the output node layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_ARC: Arc layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

topological_polygon(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
node_type: str = 'node_type',
request: qgis.core.QgsFeatureRequest | None = None,
out_poly_path: str | None = None,
out_arc_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Splits the polygons to match the topological view of the arc. Arc “eid” and “pid” fields will be updated to match the “pid” polygon fields The fields will be overwritten if it already exists.

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of Arc

  • node_layer (QgsVectorLayer) – Layer of Node

  • node_type (Field that store the node tpye (O,L,T,X)) – str

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of polygon_layer, defaults to None

  • out_poly_path (Optional[str], optional) – Path for the output polygon layer if None it’ll create a memory layer, defaults to None

  • out_arc_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Arc layer

Type renvoyé:

Dict[str, QgsVectorLayer]

simplify_arc(
arc_layer: qgis.core.QgsVectorLayer,
poly_layer: qgis.core.QgsVectorLayer,
tolerance: float = 1.0,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Simplifies arcs with a douglas-peucker algorithm. The resulting linear geometry is constrained inside an englobing polygon. Polygon and arc can share an unique identifier field “pid” to speed up the process

If no solution was found the original geometry will be returned.

Paramètres:
  • arc_layer (QgsVectorLayer) – Layer of LineString

  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • tolerance (float, optional) – Shift tolerance (meters), defaults to 1.0

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of arc_layer, defaults to None

  • output_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_ARC: Arc layer

Type renvoyé:

Dict[str, QgsVectorLayer]

split_by_interval(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
node_type: str = 'node_type',
length: float = 25,
request: qgis.core.QgsFeatureRequest | None = None,
out_poly_path: str | None = None,
out_arc_path: str | None = None,
out_node_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Splits the polygons at a regular interval spiecifed by the length parameter. All the PK and FK will be updated (vid, eid, pid, src_vid, tgt_vid) If the cutted hedge is below the speicifed length the split will be ignored.

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of Arc

  • node_layer (QgsVectorLayer) – Layer of Node

  • node_type (Field that store the node tpye (O,L,T,X)) – str

  • length (Minimal length of the hedge, defaults to 20.) – float, optional

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of polygon_layer, defaults to None

  • out_poly_path (Optional[str], optional) – Path for the output polygon layer if None it’ll create a memory layer, defaults to None

  • out_arc_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • out_node_path (Optional[str], optional) – Path for the output node layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Arc layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

split_by_orientation(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
node_type: str = 'node_type',
angle: float = 30,
min_length: float = 25,
request: qgis.core.QgsFeatureRequest | None = None,
out_poly_path: str | None = None,
out_arc_path: str | None = None,
out_node_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Splits polygons when orientaiton of the arc changes more than the specified angle value. A minimal length parameter allows to prevents the creation of hedge below this length.

All the PK and FK fields will be updated (vid, eid, pid, src_vid, tgt_vid) If the cutted hedge is below the speicifed length the split will be ignored.

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of Arc

  • node_layer (QgsVectorLayer) – Layer of Node

  • node_type (Field that store the node tpye (O,L,T,X)) – str

  • angle (float, optional) – Length of the new segments. If the last created segments is below the provided value it’ll be skept, defaults to 30.

  • min_length (Minimal length of the hedge, defaults to 25.) – float, optional

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of polygon_layer, defaults to None

  • out_poly_path (Optional[str], optional) – Path for the output polygon layer if None it’ll create a memory layer, defaults to None

  • out_arc_path (Optional[str], optional) – Path for the output arc layer if None it’ll create a memory layer, defaults to None

  • out_node_path (Optional[str], optional) – Path for the output node layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Arc layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

length(
layer: qgis.core.QgsVectorLayer,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes length of a LineString geometry from a Layer with an “eid” field. The results will be stored inside a field called “length”. The field will be overwritten if it already exists.

Paramètres:
  • layer (QgsVectorLayer) – Layer of linear feature

  • request (Optional[QgsFeatureRequest], optional) – Subset of feature to work on, defaults to None

  • output_path (Optional[str], optional) – Path to write the results at, defaults to None

  • context (QgsProcessingContext, optional) – Context to store the temporary layer, defaults to QgsProcessingContext()

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Arc layer

Type renvoyé:

Dict[str, QgsVectorLayer]

orientation(
layer: qgis.core.QgsVectorLayer,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes orientation of a LineString geometry from a Layer with an “eid” field. The results will be stored inside a field called “direction”. The field will be overwritten if it already exists.

Paramètres:
  • layer (QgsVectorLayer) – Layer of linear feature

  • request (Optional[QgsFeatureRequest], optional) – Subset of feature to work on, defaults to None

  • output_path (Optional[str], optional) – Path to write the results at, defaults to None

  • context (QgsProcessingContext, optional) – Context to store the temporary layer, defaults to QgsProcessingContext()

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Arc layer

Type renvoyé:

Dict[str, QgsVectorLayer]

shape(
layer: qgis.core.QgsVectorLayer,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes shape metrics of a polygon geometry from a layer with an “pid” field. The shape metrics are the following:

  • elongation: Indicates the degree of stretching of a polygon. However, this indicator is not very reliable for complex shapes (e.g., U-shaped polygons). Values range between 0 (highly stretched) and 1 (less stretched).

  • compactness: Indicates the density of a polygon. Values range between 0 (not compact) and 1 (highly compact).

  • convexity: Indicates the regularity of the polygon’s outline, its sphericity. Values range between 0 (non-convex) and 1 (convex).

The results will be stored inside fields called “elongation, compactness, convexity”. The field will be overwritten if it already exists.

Paramètres:
  • layer (QgsVectorLayer) – Layer of polygon feature

  • request (Optional[QgsFeatureRequest], optional) – Subset of feature to work on, defaults to None

  • output_path (Optional[str], optional) – Path to write the results at, defaults to None

  • context (QgsProcessingContext, optional) – Context to store the temporary layer, defaults to QgsProcessingContext()

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

width(
polygon_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
request: qgis.core.QgsFeatureRequest | None = None,
methods: List[int] | List[Enum] | int | Enum = [WidthFields.APPROX],
distance: float = 10.0,
percentile: int | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes width of a polygon geometry from a layer with a “pid” field.

The results will be stored inside fields called “width_*”. The mean, median, min, max and std will be computed. The fields will be overwritten if it already exists.

Two methods are available :

  • accurate : slower but more accurate. Use transect perpendicular to the median axis to estimate the width.

  • approximative : faster but less accurate. Use the property of the median axis to estimate the width of a polygon.

The distance parameter is the interval between each width computation. The smaller it gets and the longer the algorithm will take but width will be me more accurate.

An optional percentile parameter is available allowing to remove outliers in widths values before staitstic computation. An equal slice will be removed from each extremities, for example a percentile of 25 will remove the first and last quartile.

In both methods, if the length of the hedge is shorter than the specified distance plus an offset of 2 meters (required to allow multiple width samples), the width fields will be set to NULL.

Paramètres:
  • polygon_layer (QgsVectorLayer) – layer of Polygon

  • arc_layer (QgsVectorLayer) – layer of Linestring

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of polygon features, defaults to None

  • methods (Union[List[int], List[Enum], int, Enum], defaults to [Method.APPROX]) – Methods to compute width with. Can be APPROX (1) or ACCURATE (0) or both

  • distance (float) – Distance between each node that’ll be used either for transect or semi distance computation, defaults to 3m.

  • percentile (Optional[int], optional) – Percentile to use to compute iqr and remove outliers, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

height(
layer: qgis.core.QgsVectorLayer,
raster: qgis.core.QgsRasterLayer,
band: int = 1,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes height metrics of a Polygon geometry from a Layer with an “pid” field with the help of a DHM.

The results will be stored inside fields called “height_*”. The mean, median, min, max and std will be computed. The fields will be overwritten if it already exists.

Paramètres:
  • layer (QgsVectorLayer) – Layer of polygon

  • raster (QgsRasterLayer) – DHM raster

  • band (int) – Band index, default to one

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

strata_proportion(
layer: qgis.core.QgsVectorLayer,
raster: qgis.core.QgsRasterLayer,
band: int = 1,
bins: List[float] | None = None,
spatial: bool = False,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
output_spatial: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes strata proportion within a polygon geometry from a layer with a “pid” field with the help of a DHM.

Returns each height category as a percentage in the polygon layer’s fields. It is also possible to ask for a spatial representation of each category.

The lower boundary and upper boundary are assumed to be 0 and maximum values of the height raster, respectively. By default, AFAC strata are used: [0 - 0.3[, [0.3 - 2[, [2 - 7[, [7 - max value].

The nb_strata field will show the number of strata. The dom_strata field will show the strata with the most overlap

The fields will be overwritten if it already exists.

Paramètres:
  • layer (QgsVectorLayer) – Layer of polygon

  • raster (QgsRasterLayer) – DHM raster

  • band (int) – Band index, default to one

  • bins (Optional[List[float]]) – Bins for the strata edges, default to [0.3, 2, 7] (meters)

  • spatial (bool) – Output a spatial representation of the bins, default to False

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • output_spatial (Optional[str], optional) – Path for the optional spatial representation output if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

  • OUTPUT_SPATIAL: Polygon layer, optional

Type renvoyé:

Dict[str, QgsVectorLayer]

topographic_position(
layer: qgis.core.QgsVectorLayer,
raster: qgis.core.QgsRasterLayer,
band: int = 1,
search: float = 100,
skip: float = 50,
kernel_size: int = 7,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes the topographic position of an hedge using a DTM.

The results will be stored in a topo_position field. The fields will be overwritten if it already exists.

The default parameter values work well for a 5 meters resolution DTM, and the DTM extent should be slightly bigger than the vector layers” extent, as the search and skip parameters need contextual information. If it is not possible, hedges in the border of the study area might be given the wrong position or no data as a result.

The search parameter represents the radius in meters for searching terrain shapes. A higher value will give more global terrain shapes.

The skip parameter is the radius in meters where the terrain shapes will be ignored. A higher value will ignore bigger changes in topography.

The kernel radius parameter is used to further remove local changes. A higher resolution DTM should use a bigger kernel (5 or 7).

Paramètres:
  • polygon_layer (QgsVectorLayer) – Layer of Polygon

  • raster (QgsRasterLayer) – Elevation raster (DTM)

  • band (int) – Band index, default to one

  • search (float) – Neighbour context in meters for computing terrain form. Defaults to 100.

  • skip (float) – Neighbour context to skip to avoid micro topography. Defaults to 50.

  • kernel_size (int) – Majority filter kernel radius (odd). Defaults to 100.

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of polygon features, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

relative_orientation(
polygon_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
raster: qgis.core.QgsRasterLayer,
band: int = 1,
kernel_size: int = 7,
tolerance: int = 15,
min_slope: int = 3,
use_geomorphon: bool = False,
search: int = 100,
skip: int = 50,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes the relative orientation of an hedge in the slope.

The results will be stored in a slope_position field. It can either be perpendicular, parallel, diagonal, or no slope. The fields will be overwritten if it already exists.

The hedge orientation will be computed unless if found in the arc layer attribute table. If the orientation stored in the attribute table does not reflect the current hedge you should delete the fields.

The median filter allows reducing noise induced by special features (like steep river banks).

Offset tolerance allows deviating from the perpendicular between the hedge orientation and a slope orientation.

A minimum slope parameter determines if the hedge is on a slope or not, and topographic position can be used to automatically categorize hedges inside a ridge or a valley with no slope. Topographic position can either be computed in the algorithm or users can use the topo_pos field if they already have computed topographic_position.

Note: The use of topographic position will increase the “no slope” category. This will increase further as the skip distance increases. Recommended values for a 5 meters resolution DTM are to search 100 meters and skip either 0 or 50 meters.

Paramètres:
  • polygon_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of Linestring

  • raster (QgsRasterLayer) – Elevation raster (DTM)

  • band (int) – Band index, default to one

  • kernel_size (int) – Median filter kernel radius in pixels (odd). Defaults to 7.

  • tolerance (int, optional) – Angle tolerance between the slope aspect and hedge orientation, defaults to 15

  • min_slope (int, optional) – Below the hedge will be considered on flat ground, defaults to 3

  • use_geomorphon (bool, optional) – If True will use geomorphon to classify ridge and valley hedge as flat. If a topo_position field is available it’ll use it, defaults to False.

  • search (float) – Neighbour context in meters for computing terrain form. Defaults to 100.

  • skip (float) – Neighbour context to skip to avoid micro topography. Defaults to 50.

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of polygon features, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

euclidean_distance_to_forest(
node_layer: qgis.core.QgsVectorLayer,
forest_layer: qgis.core.QgsVectorLayer,
id_field: str,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes the euclidean distance of an hedge to the closest forest.

The results will be stored in a forest_dist field and the unique identifier of the forest in a forest_id field. The fields will be overwritten if it already exists.

Paramètres:
  • node_layer (QgsVectorLayer) – Layer of arc used to fetch

  • forest_layer (QgsVectorLayer) – Forest layer

  • id_field (int) – Unique identifier field of the forest

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of polygon features, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

connectivity(
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
poly_layer: qgis.core.QgsVectorLayer | None = None,
threshold: float = 0.0,
override: bool = False,
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes the connectivity metrics of hedge sub-networks.

The results will be stored inside fields called the selected metrics name. The fields will be overwritten if it already exists.

The sub-network is composed of all topologically connected arcs, i.e., all connected hedges forming a connected component (sub-network). A spatial tolerance parameter can be provided to consider that spatially disjoint topological arcs belong to the same sub-network.

If the layer already have a network_id field the network will be reconstructed from it. The n_threshold field is used if its value is different from 0. This value is identical for all hedges in the input layer.

Paramètres:
  • arc_layer (QgsVectorLayer) – Layer of linestring

  • node_layer (QgsVectorLayer) – Layer of node

  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • threshold (bool) – Spatial threshold to consider hedges in the same network. The threshold is applied between the polygons if a layer is provided, defaults to 0.0

  • override – If True will reconstruct the network and discard fields if available, defaults to False

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of arc_layer, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Arc layer

Type renvoyé:

Dict[str, QgsVectorLayer]

network_distance_to_forest(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
forest_layer: qgis.core.QgsVectorLayer,
id_field: str,
threshold: float = 0.0,
override: bool = False,
request: qgis.core.QgsFeatureRequest | None = None,
out_arc_path: str | None = None,
out_node_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes the distance between a hedge sub-network and the forest closest to that sub-network.

The results will be stored in a n_forest_dist field and the unique identifier of the forest in a n_forest_id field. The fields will be overwritten if it already exists.

The sub-network is composed of all topologically connected arcs, i.e., all connected hedges forming a connected component (sub-network). A spatial tolerance parameter can be provided to consider that spatially disjoint topological arcs belong to the same sub-network.

If the layer already have a network_id field the network will be reconstructed from it. The n_threshold field is used if its value is different from 0. This value is identical for all hedges in the input layer.

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of linestring

  • node_layer (QgsVectorLayer) – Layer of node

  • forest_layer (QgsVectorLayer) – Polygon layer of forest

  • id_field (str) – Unique identifier field name of the forest

  • threshold (bool) – Spatial threshold to consider hedges in the same network. The threshold is applied between the polygons if a layer is provided, defaults to 0.0

  • override – If True will reconstruct the network and discard fields if available, defaults to False

  • out_arc_path (Optional[str], optional) – Path for the output layer

  • out_node_path (Optional[str], optional) – Path for the output layer

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of polygon features, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_ARC: Arc layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

grid(
grid_layer: qgis.core.QgsVectorLayer,
metrics: List[int] | List[GridFields] | int | GridFields,
arc_layer: qgis.core.QgsVectorLayer | None = None,
node_layer: qgis.core.QgsVectorLayer | None = None,
poly_layer: qgis.core.QgsVectorLayer | None = None,
node_type: str | None = 'node_type',
forest_field: str | None = 'n_forest_dist',
request: qgis.core.QgsFeatureRequest | None = None,
output_path: str | None = None,
context: qgis.core.QgsProcessingContext = qgis.core.QgsProcessingContext,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes landscape metrics for each tile of a grid layer The grid layer must be polygonal and can be created with the native qgis algorithm: create grid Landscape metrics can be:

  • Count O - degree 1 nodes [0].

  • Count L - degree 2 nodes [1].

  • Count T - degree 3 nodes [2].

  • Count X - degree 4 nodes [3].

  • Count M - degree 5+ nodes [4].

  • Icon [5]: Connectivity index, weighted sum of hedge intersections.

  • Icoh (%) [6]: Consistency index, percentage of hedge intersections with other hedges and forest/grove over all hedge extremities;

  • Density (ml/ha) [7]: Total length of hedges bring back to hectare;

  • Density (%) [8]: Density of hedge for each tile;

  • Icod [9]: Density and structure of bocage index;

  • Total length [10]: Sum of arc length inside each tile

Some indices need additional data to be computed:

  • Icoh and Icod needs a field of distance to the forest from the “Network distance to forest” tool;

  • Density (%) and Icod needs a polygon layer of hedges;

  • Density (ml/ha) and total length needs an arc layer of hedges. »

The results will be stored inside fields called the selected metrics name. The fields will be overwritten if it already exists.

Paramètres:
  • grid_layer (QgsVectorLayer) – Layer of polygonal grid

  • metrics (Union[List[int], List[Enum], int, Enum]) – Metrics available from 0 to 10 included

  • arc_layer (Optional[QgsVectorLayer]) – Layer of linestring, defaults to None

  • node_layer (Optional[QgsVectorLayer]) – Layer of node, defaults to None

  • poly_layer (Optional[QgsVectorLayer]) – Layer of Polygon, defaults to None

  • node_type (Optional[str]) – node type fields. Only used for node type count metrics, defaults to “node_type”

  • forest_field (bool) – Forest distance field in node layer. Only used for icohn defaults to “forest_id”

  • request (Optional[QgsFeatureRequest], optional) – Request to work on a subset of features of grid_layer, defaults to None

  • output_path (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • context (QgsProcessingContext, optional) – Qgis context for avoiding gotcha, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

extraction_from_lidar(
las: qgis.core.QgsPointCloudLayer,
category: List[float] = [4, 5],
rst_res: float = 1,
min_area: float = 20,
tolerance: float = 0.25,
hole_size: float = 50,
opening: int = 20,
forest_area: int = 5000,
grove_area: int = 500,
output_forest: str = 'TEMPORARY_OUTPUT',
output_grove: str = 'TEMPORARY_OUTPUT',
output_hedge: str = 'TEMPORARY_OUTPUT',
output_tree: str = 'TEMPORARY_OUTPUT',
) Dict[str, qgis.core.QgsVectorLayer][source]#

Performs the extraction module with a point cloud layer as input All the parameters are not available and intermediate layers are not returned.

Paramètres:
  • category (List[float])) – Vegetation category to keep. Accepted value are 3,4,5, defaults to [4,5]

  • resolution (Optional[float], optional) – Output resolution, defaults to 1

  • min_area (float, optional) – Minimum area of geometries, defaults to 20

  • tolerance (float, optional) – Simplificaiton tolerance of the geometries, defaults to 0.25

  • hole_size (float, optional) – Minimum hole size in the geometries, defaults to 50

  • openening (int, optional) – Morphological opening value to disconnect continuous elements, defaults to 20

  • forest_area (int, optional) – Minimum size of an element to be a forest, defaults to 5000

  • grove_area (int, optional) – Minimum size of an element to be a grove, defaults to 500

  • output_forest (str) – Path of the output forest layer, defaults to TEMPORARY_OUTPUT

  • output_grove (str) – Path of the output grove layer, defaults to TEMPORARY_OUTPUT

  • output_hedge – Path of the output hedge layer, defaults to TEMPORARY_OUTPUT

  • output_tree (str) – Path of the output tree layer, defaults to TEMPORARY_OUTPUT

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • FOREST: Forest polygon layer

  • GROVE: Grove polygon layer

  • HEDGE: Hedge polygon layer

  • TREE: Tree polygon layer

Type renvoyé:

Dict[str, QgsVectorLayer]

data_preparation(
poly_layer: qgis.core.QgsVectorLayer,
threshold: float = 30.0,
min_width: float = -1.0,
out_poly: str | None = None,
out_arc: str | None = None,
out_node: str | None = None,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Performs the data preparation module with a polygon layer as input All the parameters are not available and itnermediate layers are not returned

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • min_width (float, optional) – Minimal width used for densification, defaults to -1.0

  • tolerance – Dangle length (threshold) tolerance, defaults to 10.0 From threshold - tolerance to threshold width of the polygon will be measured.

  • out_poly – Path for the output polygon layer

if None it’ll create a memory layer, defaults to None :type out_poly: Optional[str], optional :param out_arc: Path for the output arc layer

if None it’ll create a memory layer, defaults to None

Paramètres:

out_node – Path for the output node layer

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Arc layer

  • OUTPUT_ERROR: Error layer for the arc

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

morphology(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
methods: List[int] | List[Enum] | int | Enum = [WidthFields.APPROX],
distance: float = 10.0,
out_poly: str | None = None,
out_arc: str | None = None,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes all available morphology metrics All the parameters are not available and itnermediate layers are not returned

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of polygon feature

  • arc_layer (QgsVectorLayer) – Layer of linear feature

  • methods (Union[List[int], List[Enum], int, Enum], defaults to [Method.APPROX]) – Methods to compute width with. Can be APPROX (1) or ACCURATE (0) or both

  • distance – Distance between each node that’ll be used either for transect

or semi distance computation, defaults to 3m. :type distance: float :param out_poly: Path to write the results at, defaults to None :type out_poly: Optional[str], optional :param out_arc: Path to write the results at, defaults to None :type out_arc: Optional[str], optional

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_ARC: Line layer

Type renvoyé:

Dict[str, QgsVectorLayer]

physiognomy(
poly_layer: qgis.core.QgsVectorLayer,
dhm: qgis.core.QgsRasterLayer,
band: int = 1,
bins: List[float] | None = None,
spatial: bool = False,
out_poly: str | None = None,
out_spatial: str | None = None,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes all available physiognomy metrics All the parameters are not available and itnermediate layers are not returned

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of polygon

  • dhm (QgsRasterLayer) – DHM raster

  • band (int) – Band index, default to one

  • bins (Optional[List[float]]) – Bins for the strata edges, default to [0.3, 2, 7] (meters)

  • spatial (bool) – Output a spatial representation of the bins, default to False

  • out_poly (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • out_spatial (Optional[str], optional) – Path for the optional spatial representation output if None it’ll create a memory layer, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT: Polygon layer

  • OUTPUT_SPATIAL: Polygon layer, optional

Type renvoyé:

Dict[str, QgsVectorLayer]

context(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
forest_layer: qgis.core.QgsVectorLayer,
id_field: str,
dtm: qgis.core.QgsRasterLayer,
band: int = 1,
search: float = 100,
skip: float = 50,
kernel_size: int = 7,
tolerance: int = 15,
min_slope: int = 3,
out_poly: str | None = None,
out_node: str | None = None,
) Dict[str, qgis.core.QgsVectorLayer][source]#

Computes all available physiognomy metrics All the parameters are not available and itnermediate layers are not returned

Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of polygon

  • arc_layer (QgsVectorLayer) – Layer of Linestring

  • node_layer (QgsVectorLayer) – Layer of node

  • forest_layer (QgsVectorLayer) – Layer of forest

  • dtm (QgsRasterLayer) – DTM raster

  • id_field (int) – Unique identifier field of the forest

  • band (int) – Band index, default to one

  • search (float) – Neighbour context in meters for computing terrain form. Defaults to 100.

  • skip (float) – Neighbour context to skip to avoid micro topography. Defaults to 50.

  • kernel_size (int) – Majority and median filter kernel radius (odd). Defaults to 100.

  • tolerance (int, optional) – Angle tolerance between the slope aspect and hedge orientation, defaults to 15

  • min_slope (int, optional) – Below the hedge will be considered on flat ground, defaults to 3

  • out_poly (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

  • out_node (Optional[str], optional) – Path for the output layer if None it’ll create a memory layer, defaults to None

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_POLY: Polygon layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

network(
poly_layer: qgis.core.QgsVectorLayer,
arc_layer: qgis.core.QgsVectorLayer,
node_layer: qgis.core.QgsVectorLayer,
forest_layer: qgis.core.QgsVectorLayer,
id_field: str,
threshold: float = 0.0,
override: bool = False,
out_arc: str | None = None,
out_node: str | None = None,
) Dict[str, qgis.core.QgsVectorLayer][source]#
Paramètres:
  • poly_layer (QgsVectorLayer) – Layer of Polygon

  • arc_layer (QgsVectorLayer) – Layer of linestring

  • node_layer (QgsVectorLayer) – Layer of node

  • forest_layer (QgsVectorLayer) – Polygon layer of forest

  • id_field (str) – Unique identifier field name of the forest

  • threshold (bool) – Spatial threshold to consider hedges in the same network. The threshold is applied between the polygons if a layer is provided, defaults to 0.0

  • override – If True will reconstruct the network and discard fields if available, defaults to False

  • out_arc (Optional[str], optional) – Path for the output layer

  • out_node (Optional[str], optional) – Path for the output layer

Renvoie:

A dict with QgsVectorLayer as values, with keys being:

  • OUTPUT_ARC: Arc layer

  • OUTPUT_NODE: Node layer

Type renvoyé:

Dict[str, QgsVectorLayer]

property exit#

Close QgisApp.