airbornegeo.block_reduce#
- block_reduce(data, reduction, *, spacing, reduce_by, groupby_column=None, **kwargs)[source]#
Reduce data by line based on the column(s) provided by reduce_by and the reduction function. For example, if ‘reduce_by’ is ‘distance_along_line’, ‘spacing’ is 1000, and ‘reduction’ is np.mean’, then the data will be reduced by taking the mean value along every 1 km. If ‘reduce_by’ is ‘unixtime’, this would take the mean of every 1000 seconds. If ‘reduce_by’ is (‘easting’, ‘northing’), this would take the mean of every point in a 1x1 km block. The reduction function can be any function that takes an array of values and returns a single value, such as np.mean, np.median, np.max, etc. The function will return a new dataframe with the reduced data.
- Parameters:
data (
DataFrame) – DataFrame containing the data to be reduced.reduction (
Callable[...,float|int]) – function to use in reduction, e.g. np.meanspacing (
float) – The spacing to reduce the data by, in the same units as whatever column is specified by reduce_byreduce_by (
str|tuple[str,str]) – Column name(s) to reduce by. If a single column name is provided, the data will be reduced by only column. If a tuple of two column names are provided, the data will be reduced by both columns, e.g. in 1x1 km blocks if the columns are ‘easting’ and ‘northing’.groupby_column (
str|None) – Column name to group by before sorting by time, by default None.kwargs (Any) – Any additional keyword arguments to pass to verde.BlockReduce.
- Returns:
DataFrame with reduced data.
- Return type: