wolfhece.analyze_poly

Module Contents

class wolfhece.analyze_poly.Array_analysis_onepolygon(wa: wolfhece.wolf_array.WolfArray, polygon: wolfhece.PyVertexvectors.vector, buffer_size: float = 0.0)[source]

Class for values analysis of an array based on a polygon.

This class select values insides a polygon and plot statistics of the values.

The class is designed to be used with the WolfArray class and the vector class from the PyVertexvectors module.

Plots of the values distribution can be generated using seaborn or plotly.

_wa[source]
_selected_cells = None[source]
_values = None[source]
property centroid: shapely.geometry.Point[source]

Get the centroid of the polygon as a Point object.

Returns:

Shapely Point object representing the centroid of the polygon

values(which: Literal['Mean', 'Std', 'Median', 'Sum', 'Volume', 'Values', 'Area']) pandas.DataFrame | float[source]

Get the values as a pandas DataFrame

Parameters:

which – Mean, Std, Median, Sum, Volume, Values

as_vector(add_values: bool = True)[source]

Return a copy of the polygon with the values as attributes.

select_cells(mode: Literal['polygon', 'buffer'] = 'polygon', **kwargs)[source]

Select the cells inside the polygon.

Parameters:
  • mode – ‘polygon’ or ‘buffer’

  • kwargs – ‘polygon’ for polygon selection or ‘buffer’ for buffer size

For polygon selection, the polygon must be provided in kwargs or use the polygon set during initialization. For buffer selection, the buffer size in meter must be provided in kwargs.

_select_cells_polygon(selection_poly: wolfhece.PyVertexvectors.vector = None)[source]

Select the cells inside the polygon

_select_cells_buffer(buffer_size: float = 0.0)[source]

Select the cells inside the buffer of the polygon

compute_values()[source]

Get the values of the array inside the polygon

_add_area2velues()[source]

Add the area of the polygon to the values

property n_selected_cells: int[source]

Get the number of selected cells

get_selection() numpy.ndarray[source]

Get the selected cells as a numpy array of coordinates.

Returns:

numpy array of shape (n, 2) with the coordinates of the selected cells

reset_selection()[source]

Reset the selection of cells

plot_values(show: bool = True, bins: int = 100, engine: Literal['seaborn', 'plotly'] = 'seaborn')[source]

Plot a histogram of the values

plot_values_seaborn(bins: int = 100, show: bool = True)[source]

Plot a histogram of the values

plot_values_plotly(bins: int = 100, show: bool = True)[source]

Plot a histogram of the values

property has_values: bool[source]

Check if there useful values

property has_strictly_positive_values: bool[source]

Check if there useful values

distribute_values(bins: list[float])[source]

Distribute the values in bins

Parameters:

bins – list of bin edges

Returns:

pandas DataFrame with the counts of values in each bin

class wolfhece.analyze_poly.Array_analysis_polygons(wa: wolfhece.wolf_array.WolfArray, polygons: wolfhece.PyVertexvectors.zone, buffer_size: float = 0.0)[source]

Class for values analysis of an array based on a polygon.

This class select values insides a polygon and plot statistics of the values.

The class is designed to be used with the WolfArray class and the vector class from the PyVertexvectors module.

Plots of the values distribution can be generated using seaborn or plotly.

_wa[source]
_polygons[source]
_has_buffer[source]
_zone[source]
_active_categories[source]
as_zone(add_values: bool = True) wolfhece.PyVertexvectors.zone[source]

Convert the analysis to a zone of polygons

property _areas: list[float][source]

Get the areas of the polygons in the zone

property all_categories: list[str][source]

Get the name of the building categories from the Polygons

property active_categories: list[str][source]

Get the active categories for the analysis

activate_category(category_name: str)[source]

Activate a category for the analysis

Parameters:

category_name – name of the category to activate

deactivate_category(category_name: str)[source]

Deactivate a category for the analysis

Parameters:

category_name – name of the category to deactivate

_check_names()[source]

Check if the names of the polygons are unique

reset_selection()[source]

Reset the selection of cells in all polygons

get_values() pandas.DataFrame[source]

Get the values of all polygons in the zones as a pandas DataFrame.

One column per polygon with the values.

get_geometries() pandas.DataFrame[source]

Get the centroids of all polygons in the zone as a pandas DataFrame.

Returns:

pandas DataFrame with the centroids of the polygons

get_geodataframe_with_values(epsg: int = 31370) geopandas.GeoDataFrame[source]

Create a GeoDataFrame with the centroids and values of the polygons.

Values are added as a column named ‘Values’ as Numpy array.

property polygons: wolfhece.PyVertexvectors.zone[source]

Get the zone of polygons

property keys: list[str][source]

Get the names of the polygons in the zone

update_values()[source]

Update the polygons values in the zone

plot_values(show: bool = True, bins: int = 100, engine: Literal['seaborn', 'plotly'] = 'seaborn')[source]

Plot a histogram of the values

plot_values_seaborn(bins: int = 100, show: bool = True)[source]

Plot a histogram of the values

plot_values_plotly(bins: int = 100, show: bool = True)[source]

Plot a histogram of the values

count_strictly_positive() int[source]

Count the number of polygons with values greater than zero

values(which: Literal['Mean', 'Std', 'Median', 'Sum', 'Volume', 'Area']) pandas.Series[source]

Get the values as a pandas DataFrame

Parameters:

which – Mean, Std, Median, Sum, Volume

Returns:

pandas DataFrame with the values for each polygon

distribute_polygons(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area']) pandas.DataFrame[source]

Distribute the values of each polygon in bins

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

Returns:

pandas DataFrame with the counts of values in each bin for each polygon

plot_distributed_values(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'], show: bool = True, engine: Literal['seaborn', 'plotly'] = 'seaborn')[source]

Plot the distribution of values in bins for each polygon

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

  • show – whether to show the plot

  • engine – ‘seaborn’ or ‘plotly’

plot_distribution_seaborn(distribution: pandas.DataFrame, show: bool = True)[source]

Plot the distribution of values in bins using seaborn

Parameters:
  • distribution – pandas DataFrame with the counts of values in each bin

  • show – whether to show the plot

plot_distribution_plotly(distribution: pandas.DataFrame, show: bool = True)[source]

Plot the distribution of values in bins using plotly

Parameters:
  • distribution – pandas DataFrame with the counts of values in each bin

  • show – whether to show the plot

clustering(n_clusters: int = 5, operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'] = 'Mean')[source]

Perform clustering on the polygons based on their values.

class wolfhece.analyze_poly.Array_analysis_zones(wa: wolfhece.wolf_array.WolfArray, zones: wolfhece.PyVertexvectors.Zones, buffer_size: float = 0.0)[source]

Class for values analysis of an array based on a Zones instance.

This class select values insides a zone of polygons and plot statistics of the values.

_wa[source]
_zones[source]
_polygons[source]
as_zones(add_values: bool = True) wolfhece.PyVertexvectors.Zones[source]

Convert the analysis to a Zones instance

reset_selection()[source]

Reset the selection of cells in all polygons

property keys: list[str][source]

Get the names of the polygons in the zones

update_values()[source]

Update the polygons values in the zones

get_values() dict[str, pandas.DataFrame][source]

Get the values of all polygons in the zones as a dictionary of pandas DataFrames

plot_values(show: bool = True, bins: int = 100, engine: Literal['seaborn', 'plotly'] = 'seaborn')[source]

Plot a histogram of the values

plot_values_seaborn(bins: int = 100, show: bool = True)[source]

Plot a histogram of the values

plot_values_plotly(bins: int = 100, show: bool = True)[source]

Plot a histogram of the values

distribute_zones(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area']) dict[str, pandas.DataFrame][source]

Distribute the values of each zone in bins

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

Returns:

pandas DataFrame with the counts of values in each bin for each zone

values(which: Literal['Mean', 'Std', 'Median', 'Sum', 'Volume', 'Area']) dict[str, pandas.Series][source]

Get the values as a dictionnary of pandas Series

Parameters:

which – Mean, Std, Median, Sum, Volume

Returns:

pandas DataFrame with the values for each polygon

class wolfhece.analyze_poly.Arrays_analysis_zones(arrays: dict[str, wolfhece.wolf_array.WolfArray], zones: wolfhece.PyVertexvectors.Zones, buffer_size: float = 0.0)[source]

Class for analysis multiples arrays based on a Zones instance. Each array must have the same shape.

_arrays[source]
_zones[source]
_xlabel = 'Value'[source]
_polygons[source]
_active_categories[source]
_active_arrays[source]
as_zones(add_values: bool = True) wolfhece.PyVertexvectors.Zones[source]

Convert the analysis to a Zones instance

property _areas: dict[str, list[float]][source]

Get the areas of the polygons in the zones

property all_categories: list[str][source]

Get the name of the building categories from the Zones

property all_arrays: list[str][source]

Get the names of all arrays

activate_array(array_name: str)[source]

Activate an array for the analysis

Parameters:

array_name – name of the array to activate

deactivate_array(array_name: str)[source]

Deactivate an array for the analysis

Parameters:

array_name – name of the array to deactivate

activate_category(category_name: str)[source]

Activate a category for the analysis

Parameters:

category_name – name of the category to activate

deactivate_category(category_name: str)[source]

Deactivate a category for the analysis

Parameters:

category_name – name of the category to deactivate

property active_arrays: list[str][source]

Get the active arrays for the analysis

property active_categories: list[str][source]

Get the active categories for the analysis

get_values() dict[str, dict[str, pandas.DataFrame]][source]

Get the values of all polygons in the zones as a dictionary of pandas DataFrames

values(which: Literal['Mean', 'Std', 'Median', 'Sum', 'Volume', 'Area']) dict[str, dict[str, pandas.Series]][source]

Get the values of all polygons in the zones as a dictionary of pandas Series

Parameters:

which – Mean, Std, Median, Sum, Volume, Area

Returns:

dictionary with zone names as keys and dictionaries of array names and their values as values

update_values()[source]

Update the polygons values in the zones for all arrays

count_strictly_positive() dict[str, int][source]

Count the number of polygons with values greater than zero for each array

count_strictly_positive_as_df(merge_zones: bool = False) pandas.DataFrame[source]

Count the number of polygons with strictly positive values for each array as a pandas DataFrame

Returns:

pandas DataFrame with the counts of strictly positive values for each array in each zone

distribute_zones(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area']) dict[str, dict[str, pandas.DataFrame]][source]

Distribute the values of each zone in bins for each array

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

Returns:

dictionary with zone names as keys and dictionaries of array names and their distributions as values

distribute_zones_as_df(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'], merge_zones: bool = False) pandas.DataFrame[source]

Distribute the values of each zone in bins for each array as a pandas DataFrame.

Date are tabulated in a DataFrame with columns ‘Zone’, ‘Array’, ‘Bin Edges’, ‘Count’. It is more convenient for plotting and analysis.

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

Returns:

pandas DataFrame with the counts of values in each bin for each array in each zone

_values_as_df(which: Literal['Mean', 'Std', 'Median', 'Sum', 'Volume', 'Area'], merge_zones: bool = False) pandas.DataFrame[source]

Get a full DataFrame with all arrays, zones and values for each polygon.

Parameters:

merge_zones – whether to merge the zones in the DataFrame

Returns:

pandas DataFrame with the counts of strictly positive values for each array in each zone

plot_count_strictly_positive(show: bool = True, engine: Literal['seaborn', 'plotly'] = 'seaborn', merge_zones: bool = False)[source]

Plot the count of strictly positive values for each array in each zone

Parameters:
  • show – whether to show the plot

  • engine – ‘seaborn’ or ‘plotly’

_plot_count_strictly_positive_seaborn(show: bool = True, merge_zones: bool = False)[source]

Plot the count of strictly positive values for each array in each zone using seaborn

Parameters:
  • counts – dictionary with zone names as keys, and dictionaries of array names and their counts as values

  • show – whether to show the plot

_plot_count_strictly_positive_plotly(show: bool = True, merge_zones: bool = False)[source]

Plot the count of strictly positive values for each array in each zone using plotly

Parameters:
  • counts – dictionary with zone names as keys, and dictionaries of array names and their counts as values

  • show – whether to show the plot

plot_distributed_values(bins: list[float] = [0.0, 0.3, 1.3, -1.0], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'] = 'Median', show: bool = True, engine: Literal['seaborn', 'plotly'] = 'seaborn', merge_zones: bool = False)[source]

Plot the distribution of values in bins for each array in each zone or merged zones. :param bins: list of bin edges :param operator: ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’ :param show: whether to show the plot :param engine: ‘seaborn’ or ‘plotly’ :param merge_zones: whether to merge the zones in the plot

_plot_distributed_values_seaborn(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'], show: bool = True, merge_zones: bool = False)[source]

Plot the distribution of values in bins for each array in each zone using seaborn

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

  • show – whether to show the plot

  • merge_zones – whether to merge the zones in the plot

_plot_distributed_values_plotly(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'], show: bool = True, merge_zones: bool = False)[source]

Plot the distribution of values in bins for each array in each zone using plotly

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

  • show – whether to show the plot

  • merge_zones – whether to merge the zones in the plot

_plot_distributed_areas_seaborn(bins: list[float], operator: Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'], show: bool = True, merge_zones: bool = False)[source]

Plot the distribution of values in bins for each array in each zone using seaborn

Parameters:
  • bins – list of bin edges

  • operator – ‘Mean’, ‘Median’, ‘Sum’, ‘Volume’, ‘Area’

  • show – whether to show the plot

  • merge_zones – whether to merge the zones in the plot

class wolfhece.analyze_poly.Building_Waterdepth_analysis(arrays: dict[str, wolfhece.wolf_array.WolfArray], zones: wolfhece.PyVertexvectors.Zones | pathlib.Path | str, buffer_size: float = 0.0, merge_zones: bool = False, thershold_area: float = 0.0)[source]

Bases: Arrays_analysis_zones

Inheritance diagram of wolfhece.analyze_poly.Building_Waterdepth_analysis

Class for water depth analysis of multiple arrays based on a Zones instance.

This class is designed to analyze water depth data from multiple arrays and zones. It inherits from Arrays_analysis_zones and provides additional methods specific to water depth analysis.

_xlabel[source]
plot_distributed_areas(bins=[0, 0.3, 1.3, -1], operator='Median', show=True, engine='seaborn', merge_zones=False)[source]
class wolfhece.analyze_poly.Slope_analysis(wa: wolfhece.wolf_array.WolfArray, trace: wolfhece.PyVertexvectors.vector)[source]

Class for slope analysis of in an array based on a trace vector.

This class allows to select cells inside a polygon or a buffer around a trace vector and compute the slope of the dike. The slope is computed as the difference in elevation between the trace and the cell divided by the distance to the trace.

The slope is computed for each cell inside the polygon or buffer and accessed in a Pandas Dataframe.

Plots of the slope distribution can be generated using seaborn or plotly.

The class is designed to be used with the WolfArray class and the vector class from the PyVertexvectors module.

_wa[source]
_trace[source]
_selection_poly = None[source]
_buffer_size = 0.0[source]
_selected_cells = None[source]
_slopes = None[source]
property slopes: pandas.DataFrame[source]

Get the slopes as a pandas DataFrame

select_cells(mode: Literal['polygon', 'buffer'] = 'polygon', **kwargs)[source]

Select the cells inside the trace

_select_cells_buffer(buffer_size: float = 0.0)[source]

Select the cells inside the buffer of the trace

_select_cells_polygon(selection_poly: wolfhece.PyVertexvectors.vector)[source]

Select the cells inside the polygon

compute_slopes()[source]

Get the slope of the dike

plot_slopes(show: bool = True, bins: int = 100, engine: Literal['seaborn', 'plotly'] = 'seaborn')[source]

Plot a histogram of the slopes

plot_slopes_seaborn(bins: int = 100, show: bool = True)[source]

Plot a histogram of the slopes

plot_slopes_plotly(bins: int = 100, show: bool = True)[source]

Plot a histogram of the slopes