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.
- 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
- 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
- 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.
- as_zone(add_values: bool = True) wolfhece.PyVertexvectors.zone [source]
Convert the analysis to a zone of polygons
- property all_categories: list[str][source]
Get the name of the building categories from the Polygons
- 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
- 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
- plot_values(show: bool = True, bins: int = 100, engine: Literal['seaborn', 'plotly'] = 'seaborn')[source]
Plot a histogram of the values
- 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
- 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.
- as_zones(add_values: bool = True) wolfhece.PyVertexvectors.Zones [source]
Convert the analysis to a Zones instance
- 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
- 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
- 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.
- as_zones(add_values: bool = True) wolfhece.PyVertexvectors.Zones [source]
Convert the analysis to a Zones instance
- 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
- 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
- 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
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.
- 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.
- 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