derevo package

Subpackages

Submodules

derevo.adjacency module

Get adjency graph method is defined here.

derevo.adjacency.get_adjacency_graph(species_in_parks: pd.DataFrame, edge_key_value: int = 1, target_parks: list[str] | None = None) nx.Graph[source]

Return adjacency graph where weight of edges equals to number of co-occurence cases.

derevo.adjacency.write_adjacency_graph_gexf(species_in_parks: pd.DataFrame, output_path: str | BinaryIO = 'adjacency_graph.gexf', edge_key_value: int = 1, target_parks: list[str] | None = None) None[source]

Write adjacency graph where weight of edges equals to number of co-occurence cases to a given file (by name or a binary file-like object) in gexf format.

derevo.combined module

Get combined graph method is defined here.

derevo.combined.get_combined_graph(plants: pd.DataFrame, cohabitation_attributes: pd.DataFrame, species_in_parks: pd.DataFrame, target_parks: list[str] | None = None) nx.Graph[source]

Returns combined graph with weights equal to number of co-occurence cases and compatability outcome in attributes.

derevo.combined.write_combined_graph_gexf(plants: pd.DataFrame, cohabitation_attributes: pd.DataFrame, species_in_parks: pd.DataFrame, target_parks: list[str] | None = None, output_path: str | BytesIO = 'combined_graph.gexf') None[source]

Write combined graph with weights equal to number of co-occurence cases and compatability outcome in attributes to a given file (by name or a binary file-like object) in gexf format.

derevo.compatability module

Get cohabitation graph method is defined here

derevo.compatability.get_compatability_graph(plants: DataFrame, cohabitation_attributes: DataFrame) Graph[source]

Return compatability graph where weights of edges equals to outcome of species interaction (1 for negative, 2 for neutral, 3 for positive).

derevo.compatability.write_compatability_graph_gexf(plants: pd.DataFrame, cohabitation_attributes: pd.DataFrame, output_path: str | BinaryIO = 'compatability_graph.gexf') None[source]

Write compatability graph where weights of edges equals to outcome of species interaction (1 for negative, 2 for neutral, 3 for positive) to a given file (by name or a binary file-like object) in gexf format.

derevo.compatability.get_compatability_for_species(species_list: list[str], compatability_graph) Graph[source]

Return compatability graph for a set of selected species.

derevo.compatability.write_compatability_for_species_gexf(species_list: list[str], compatability_graph, output_path: str | BinaryIO = 'compatability_graph.gexf') None[source]

Return compatability graph for a set of selected species.

derevo.composition module

Composition-related methods are defined here.

derevo.composition.get_compositions(plants_available: list[Plant], territory: Territory, cohabitation_attributes: list[GeneraCohabitation], plants_present: list[Plant] | None = None) list[list[Plant]][source]

Return plants composition variants list for the given parameters.

derevo.composition._intersection_check(greenery_polygon: GeoDataFrame, factor: GeoDataFrame)[source]

Determine if greenery polygon intersects with another polygon of light or limitation.

derevo.composition.get_updated_composition(plants: pd.DataFrame, plants_with_limitations_resistance: pd.DataFrame, plants_suitable_for_light: pd.DataFrame, cohabitation_attributes: pd.DataFrame, limitations: gpd.GeoDataFrame, light: gpd.GeoDataFrame, species_in_parks: pd.DataFrame, greenery_polygon: gpd.GeoDataFrame) list[nx.Graph] | None[source]

Return list of graphs with variants of updated plants composition.

derevo.composition.write_updated_composition_gexf(plants: pd.DataFrame, plants_with_limitations_resistance: pd.DataFrame, plants_suitable_for_light: pd.DataFrame, cohabitation_attributes: pd.DataFrame, limitations: gpd.GeoDataFrame, light: gpd.GeoDataFrame, species_in_parks: pd.DataFrame, greenery_polygon: gpd.GeoDataFrame, output_path_prefix: str | Iterable[BytesIO] | Iterable[str])[source]

Write variants of updated plants composition to files with given prefix or names / file-like objects given in iterator.

Return list of graphs with variants of recommended composition with account for outer factors.

Write list of graphs with variants of recommended composition with account for outer factors to files with given prefix or names / file-like objects given in iterator.

derevo.composition.get_composition_unknown(plants: DataFrame, cohabitation_attributes: DataFrame) list[Graph][source]

Return list of graphs with variants of recommended composition for a place with unknown outer factors.

derevo.composition.write_composition_unknown_gfsx(plants: pd.DataFrame, cohabitation_attributes: pd.DataFrame, output_path_prefix: str | Iterable[BytesIO] | Iterable[str] = 'new_graph') list[nx.Graph][source]

Write graphs with variants of recommended composition for a place with unknown outer factors to files with given prefix or names / file-like objects given in iterator.

derevo.optimal_resolution module

Get optimal resolution method is defined here.

derevo.optimal_resolution.get_best_resolution(plants: pd.DataFrame, plants_with_limitations_resistance: pd.DataFrame, plants_suitable_for_light: pd.DataFrame, cohabitation_attributes: pd.DataFrame, graph_axes: Axes | None = None) pd.DataFrame[source]

Return dataframe with calculated best resolutions for current collection of species and limitation factors / light variants.

If graph_axes is given, scatter plot will be drawn on it.

derevo.prepare_polygons module

Polygons preparation logic is defined here.

derevo.prepare_polygons.make_grid(polygon, edge_size: int, polygon_id: int, crs: int = 32636) gpd.GeoDataFrame | None[source]

Return grid with given edge_size.

derevo.prepare_polygons.get_ids(grid_id: DataFrame) DataFrame[source]

Unify identifiers in the given DataFrame.

derevo.prepare_polygons.green_lims(limitations: GeoDataFrame, greenery_polygons: GeoDataFrame) GeoDataFrame[source]

Overlay given limitations with greenery polygons.

derevo.territories module

Territory-related methods are defined here.

derevo.territories._geom_func(gdf: GeoDataFrame, geom: BaseGeometry) GeoDataFrame[source]

Return rows of GeoDataFrame which geometry is covered by, covers or intersect the given geometry.

derevo.territories.get_territory(greenery_polygon: BaseGeometry, global_territory: GlobalTerritory, territory_data: Territory | None = None) Territory[source]

Get territory information based on its geometry, used-defined known data and other factors polygons.

Module contents

Derevo module helps to create optimal plants compositions taking into an account their cohabitations and possible limitation factors