wolfhece.PyVertex
Author: HECE - University of Liege, Pierre Archambeau Date: 2024
Copyright (c) 2024 University of Liege. All rights reserved.
This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.
Module Contents
- class wolfhece.PyVertex.Cloud_Styles[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class wolfhece.PyVertex.wolfvertex(x: float, y: float, z: float = -99999.0)[source]
Vertex WOLF - 3 coordonnées + valeurs associées dans un dictionnaire
- dist3D(v: wolfvertex) float [source]
Return the 3D distance to another vertex
- Parameters:
v – vertex to compare
- dist2D(v: wolfvertex) float [source]
Return the 2D distance to another vertex
- Parameters:
v – vertex to compare
- addvalue(id, value)[source]
Add a value to the vertex
- Parameters:
id – key of the value
value – value to add
- limit2bounds(bounds=None)[source]
Limit the vertex to a set of bounds
- Parameters:
bounds – [[xmin, xmax], [ymin, ymax]] – floats
- is_like(v: wolfvertex, tol: float = 1e-06)[source]
Return True if the vertex is close to another one
- Parameters:
v – vertex to compare
tol – tolerance
- class wolfhece.PyVertex.cloudproperties(lines=[], parent: cloud_vertices = None)[source]
Properties of a cloud of vertices
- class wolfhece.PyVertex.cloud_vertices(fname: str | pathlib.Path = '', fromxls: str = '', header: bool = False, toload=True, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False, bbox: shapely.geometry.Polygon = None)[source]
Bases:
wolfhece.drawing_obj.Element_To_Draw
Scatter points with associated values
Accepted formats : dxf, ascii
Ascii separator : tabulation ‘ ‘, semicolon ‘;’
‘dxf’ type is automatically finded based on file extension otherwise, ascii file is supposed.
If header exists in the first line of the file, you have to mention it by header=True in initialization.
- Total number of columns (nb) is important :
if nb >3 : the file must contain a header
if header[2].lower() == ‘z’, the file contains XYZ coordinates, otherwise all columns >1 are interpreted as values associated to XY
Number os values = nb - (2 or 3) depending if Z coordinate exists
- Data are stored in Python dictionnary :
‘vertex’ : XY or XYZ
- Each value is accessible through its headname as key :
‘headname1’ : value with headname1
‘headname2’ : value with headname2
‘headnamen’ : value with headnamen
For more information, see ‘readfile’ or ‘import_from_dxf’
- myprop: cloudproperties[source]
- find_nearest(xy: numpy.ndarray, nb: int = 1)[source]
Find nearest neighbors from Scipy KDTree structure based on a copy of the vertices
- Return :
list of distances
list of “Wolfvertex”
list of elements stored in self.myvertices
- readfile(fname: str = '', header: bool = False)[source]
Reading an ascii file with or without header
- Parameters:
fname – (str) file name
header – (bool) header in file (first line with column names)
The separator is automatically detected among : tabulation, semicolon, space, comma.
The file must contain at least 2 columns (X, Y) and may contain a third one (Z) and more (values). If values are present, they are stored in the dictionnary with their header name as key.
- import_from_dxf(fn: str = '')[source]
Importing DXF file using ezdxf library
- Parameters:
fn – file name (*.dxf)
- import_shapefile(fn: str = '', targetcolumn: str = 'X1_Y1_Z1', bbox: shapely.geometry.Polygon = None)[source]
Importing Shapefile using geopandas library
- Parameters:
fn – file name
targetcolumn – column name to be used for XYZ coordinates – ‘X1_Y1_Z1’ is used by SPW-ARNE-DCENN
- add_vertex(vertextoadd: wolfvertex = None, id=None, cloud: dict = None)[source]
Add a vertex to the cloud
- Parameters:
vertextoadd – vertex to add
id – id of the vertex – if None, the id is the length of the cloud
cloud – cloud of vertices to add – wolfvertex instances are pointed not copied
- add_vertices(vertices: list[wolfvertex])[source]
Add a list of vertices to the cloud
- plot_legend(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]
Plot OpenGL
Legend is an image texture
- plot(update: bool = False, *args, **kwargs)[source]
OpenGL plot of the cloud of vertices
FIXME : to be improved
- _updatebounds(newvert: wolfvertex = None, newcloud: dict = None)[source]
Update the bounds of the cloud
:param newvert : (optional) vertex added to the cloud :param newcloud: (optional) cloud added to the cloud
‘newvert’ or ‘newcloud’ can be passed as argument during add_vertex operation. In this way, the bounds are updated without going through all the vertices -> expected more rapid.
- find_minmax(force=False)[source]
Find the bounds of the cloud
- Parameters:
force – force the computation of the bounds
- get_xyz(key='vertex') numpy.ndarray [source]
Return the vertices as numpy array
- Parameters:
key – key to be used for the third column (Z) – ‘vertex’ or any key in the dictionnary – if ‘vertex’’, [[X,Y,Z]] are returned
- interp_on_array(myarray, key: str = 'vertex', method: Literal[linear, nearest, cubic] = 'linear')[source]
Interpolation of the cloud on a 2D array
- Parameters:
myarray – WolfArray instance
key – key to be used for the third column (Z) – ‘vertex’ or any key in the dictionnary
method – interpolation method – ‘linear’, ‘nearest’, ‘cubic’
see interpolate_on_cloud method of WolfArray for more information
- projectontrace(trace, return_cloud: bool = True, proximity: float = 99999.0)[source]
Project the cloud onto a trace (type ‘vector’)
- Parameters:
trace – vector class
return_cloud – return a cloud or the lists [s],[z]
proximity – search distance for projection
- Returns:
New cloud containing the position information on the trace and altitude (s,z) else:
s,z: 2 lists of floats
- Return type:
if return_cloud