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

wolfhece.PyVertex.msg[source]
wolfhece.PyVertex.getRGBfromI(rgbint: int)[source]

Convert integer to RGB

wolfhece.PyVertex.getIfromRGB(rgb: list | tuple)[source]

Convert RGB to integer

wolfhece.PyVertex.circle(x: float, y: float, r: float, numseg: int = 20)[source]
wolfhece.PyVertex.cross(x: float, y: float, r: float)[source]
wolfhece.PyVertex.quad(x: float, y: float, r: float)[source]
class wolfhece.PyVertex.Cloud_Styles[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.PyVertex.Cloud_Styles

Generic enumeration.

Derive from this class to define new enumerations.

POINT = 0[source]
CIRCLE = 1[source]
CROSS = 2[source]
QUAD = 3[source]
class wolfhece.PyVertex.wolfvertex(x: float, y: float, z: float = -99999.0)[source]

Vertex WOLF - 3 coordonnées + valeurs associées dans un dictionnaire

x: float[source]
y: float[source]
z: float[source]
values: dict[source]
as_shapelypoint()[source]

Return a shapely Point

copy()[source]

Return a copy of the vertex

getcoords()[source]

Return the coordinates as a numpy array

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

getvalue(id)[source]

Return a value from the vertex

Parameters:

id – key of the value

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

used: bool[source]
color: int[source]
width: int[source]
style: int[source]
alpha: int[source]
filled: bool[source]
legendvisible: bool[source]
transparent: bool[source]
flash: bool[source]
legendtext: str[source]
legendrelpos: int[source]
legendx: float[source]
legendy: float[source]
legendbold: bool[source]
legenditalic: bool[source]
legendunderlined: bool[source]
legendfontname[source]
legendfontsize: int[source]
legendcolor: int[source]
legendpriority: int[source]
legendorientation: int[source]
legendwidth: int[source]
legendheight: int[source]
extrude: bool = False[source]
myprops: wolfhece.PyParams.Wolf_Param[source]
fill_property()[source]
defaultprop()[source]

Default properties

destroyprop()[source]
show()[source]
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

Inheritance diagram of wolfhece.PyVertex.cloud_vertices

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’

filename: str[source]
myvertices: dict[int, dict['vertex':wolfvertex, str:float]][source]
xbounds: tuple[source]
ybounds: tuple[source]
zbounds: tuple[source]
myprop: cloudproperties[source]
mytree: scipy.spatial.KDTree[source]
create_kdtree()[source]

Set a Scipy KDTree structure based on a copy of the vertices

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

init_from_nparray(array)[source]

Fill-in from nparray – shape (n,3)

check_plot()[source]

The cloud is plotted – useful for mapviewer

uncheck_plot(unload=True)[source]

The cloud is not plotted – useful for mapviewer

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

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

show_properties()[source]

Show properties of the cloud

_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

iter_on_vertices()[source]

Iteration on vertices

get_multipoint()[source]

Return the cloud as a Shapely MultiPoint

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