FLOCK.SpatialFeats
index
c:\users\james\gitrepos\gps-ruck\flock\spatialfeats.py

Functions for extracting spatial features
 
including centroid distance (stretch index), nearest neighbor, surface area (convex hull) and voronoi areas

 
Modules
       
numpy
pandas

 
Functions
       
get_cent_dist(movements, UTM=True)
Get each soldier distance to the group's centroid
First step in calculating 'Stretch Index', can also use for individual's 'stretch'
 
Args:
    movements (list): list of movement period DataFrames
    UTM (bool, optional): True if using UTM data, false if GPS data. Defaults to True.
 
Returns:
    cent_dists (list): list of DataFrames for each movement period, with centroid-distance time-series for each soldier
get_surface_area(movements, UTM=True)
Find the convex hull and calculate the surface area 
Creates a time series of surface areas for that squad at each timepoint
 
Args:
    movements (list): list of movement period DataFrames
    UTM (bool, optional): True if using UTM data, false if GPS data. Defaults to True.
 
Returns:
    surface_areas (list): list of surface area time-series for movement periods
get_voronoi_areas(movements, UTM=True)
Get the area for each soldier' voronoi space inside of the group's convex hull
Both the raw area and the ration of individual area / total area
 
Args:
    movements (list): list of movement period DataFrames
    UTM (bool, optional): True if using UTM data, false if GPS data. Defaults to True.
 
Raises:
    ValueError: Voronoi calculation Requires 2D input
    KeyError: Voronoi calculation can't handle NaN values
 
Returns:
    voronoi_areas (list): list of voronoi area time series for each movement period
    voronoi_ratios (list): list of voronoi area ratio time series for each movement period
neighbor_dists(movements, UTM=True)
Get distance to nearest neighbor for each soldier
 
Args:
    movements (list): list of movement period DataFrames
    UTM (bool, optional): True if using UTM data, false if GPS data. Defaults to True.
 
Returns:
    dists (list): list of DataFrames for each movement period, with nearest neighbor distance time series for each soldier
voronoi_finite_polygons_2d(vor, radius=None)
Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.
Parameters
----------
vor : Voronoi
    Input diagram
radius : float, optional
    Distance to 'points at infinity'.
Returns
-------
regions : list of tuples
    Indices of vertices in each revised Voronoi regions.
vertices : list of tuples
    Coordinates for revised Voronoi vertices. Same as coordinates
    of input vertices, with 'points at infinity' appended to the
    end.