fractopo.analysis.random_sampling module
Utilities for randomly Network sampling traces.
- class fractopo.analysis.random_sampling.NetworkRandomSampler(trace_gdf: GeoDataFrame, area_gdf: GeoDataFrame, min_radius: float, snap_threshold: float, random_choice: RandomChoice | str, name: str)
Bases:
objectRandomly sample traces inside given target area.
- area_gdf: GeoDataFrame
- static area_gdf_should_contain_polygon(area_gdf: GeoDataFrame) GeoDataFrame
Check that area_gdf contains one Polygon.
- property max_area: float
Calculate maximum area from max_radius.
- property max_radius: float
Calculate max radius from given area_gdf.
- property min_area: float
Calculate minimum area from min_radius.
- min_radius: float
- name: str
- random_area() float
Calculate random area in area range.
Range is calculated from [min_radius, max_radius[.
- random_choice: RandomChoice | str
- static random_choice_should_be_enum(random_choice: RandomChoice | str) RandomChoice
Check that random_choice is valid.
- random_network_sample(determine_branches_nodes: bool = True) RandomSample
Get random Network sample with a random target area.
Returns the network, the sample circle centroid and circle radius.
- classmethod random_network_sampler(network: Network, min_radius: float, random_choice: RandomChoice = RandomChoice.radius)
Initialize
NetworkRandomSamplerfor random sampling.Assumes that
Networktarget area is a singlePolygoncircle.
- random_radius() float
Calculate random radius in range [min_radius, max_radius[.
- random_target_circle() tuple[Polygon, Point, float]
Get random target area and its centroid and radius.
The target area is always within the original target area.
- snap_threshold: float
- property target_area_centroid: Point
Get target area centroid.
- property target_circle: Polygon
Target circle Polygon from area_gdf.
- trace_gdf: GeoDataFrame
- static trace_gdf_should_contain_traces(trace_gdf: GeoDataFrame) GeoDataFrame
Check that trace_gdf contains LineString traces.
- static value_should_be_positive(min_radius: float | int | Real) float | int | Real
Check that value is positive.