ecoscope.analysis.ecograph#

Module Contents#

ecoscope.analysis.ecograph.InterpolationOption#
class ecoscope.analysis.ecograph.Ecograph(trajectory, resolution=15, radius=2, cutoff=None, tortuosity_length=3)#

A class that analyzes movement tracking data using Network Theory.

Parameters:
  • trajectory (ecoscope.Trajectory) – Trajectory dataframe

  • resolution (float) – Pixel size, in meters

  • radius (int) – Radius to compute Collective Influence (Default : 2)

  • cutoff (int) – Cutoff to compute an approximation of betweenness index if the standard algorithm is too slow. Can be useful for very large graphs (Default : None)

  • tortuosity_length (int) – The number of steps used to compute the two tortuosity metrics (Default : 3 steps)

graphs: dict[str, networkx.Graph]#
trajectory#
resolution#
utm_crs#
features = ['dot_product', 'speed', 'step_length', 'sin_time', 'cos_time', 'weight', 'degree',...#
xmin#
ymin#
xmax#
ymax#
transform#
inverse_transform#
n_rows#
n_cols#
to_csv(output_path)#

Saves the features of all nodes in a CSV file

Parameters:

output_path (str, Pathlike) – Output path for the CSV file

Return type:

None

to_geotiff(feature, output_path, individual='all', interpolation=None, transform=None)#

Saves a specific node feature as a GeoTIFF

Parameters:
  • feature (str) – Feature of interest

  • output_path (str, Pathlike) – Output path for the GeoTIFF file

  • individual (str) – The individual for which we want to output the node feature (Default : “all”)

  • interpolation (str or None) – Whether to interpolate the feature for each step in the trajectory (Default : None). If provided, has to be one of those four types of interpolation : “mean”, “median”, “max” or “min”

  • transform (sklearn.base.TransformerMixin or None) – A feature transform method (Default : None)

Return type:

None

_get_ecograph(gdf, radius, cutoff, tortuosity_length)#
Parameters:
  • gdf (geopandas.GeoDataFrame)

  • radius (float)

  • cutoff (float | None)

  • tortuosity_length (int)

Return type:

networkx.Graph

static _update_node(G, node_id, attributes)#
Parameters:
  • G (networkx.Graph)

  • node_id (Hashable)

  • attributes (dict)

Return type:

None

static _get_day_night_value(day_night_value)#
Parameters:

day_night_value (Literal['day', 'night'])

Return type:

int

static _initialize_node(G, node_id, attributes, empty=False)#
Parameters:
  • G (networkx.Graph)

  • node_id (Hashable)

  • attributes (dict)

  • empty (bool)

Return type:

None

static _get_dot_product(x, y, z, w)#
Parameters:
  • x (list[float])

  • y (list[float])

  • z (list[float])

  • w (list[float])

Return type:

float

_get_tortuosities(lines, time_delta)#
Parameters:
  • lines (list[list[Tuple[float, float]]])

  • time_delta (float)

Return type:

Tuple[float, float]

_compute_network_metrics(G, radius, cutoff)#
Parameters:
  • G (networkx.Graph)

  • radius (float)

  • cutoff (float | None)

Return type:

None

static _compute_degree(G)#
Parameters:

G (networkx.Graph)

Return type:

None

_compute_collective_influence(G, radius)#
Parameters:
  • G (networkx.Graph)

  • radius (float)

Return type:

None

static _get_collective_influence(G, start, radius)#
Parameters:
  • G (networkx.Graph)

  • start (Hashable)

  • radius (float)

Return type:

float

static _compute_betweenness(G, cutoff)#
Parameters:
  • G (networkx.Graph)

  • cutoff (float | None)

Return type:

None

_get_feature_mosaic(feature, interpolation=None)#
Parameters:
  • feature (str)

  • interpolation (InterpolationOption | None)

Return type:

numpy.typing.NDArray

_get_feature_map(feature, individual, interpolation=None)#
Parameters:
  • feature (str)

  • individual (str)

  • interpolation (InterpolationOption | None)

Return type:

numpy.typing.NDArray

_get_regular_feature_map(feature, individual)#
Parameters:
  • feature (str)

  • individual (str)

Return type:

numpy.typing.NDArray

_get_interpolated_feature_map(feature, individual, interpolation)#
Parameters:
  • feature (str)

  • individual (str)

  • interpolation (InterpolationOption)

Return type:

numpy.typing.NDArray

ecoscope.analysis.ecograph.get_feature_gdf(input_path)#

Convert a GeoTIFF feature map into a GeoDataFrame

Parameters:

input_path (str, Pathlike) – Input path for the GeoTIFF file

Return type:

geopandas.GeoDataFrame