Skip to content

aaron-schroeder/pandas-xyz

Repository files navigation

pandas-xyz

Geospatial calculation accessor for pandas DataFrames.

Example Usage

pandas-xyz provides the .xyz DataFrame accessor:

>>> import pandas as pd
>>> import pandas_xyz

>>> df = pd.DataFrame.from_dict({
...   'lat': [40.0, 40.1, 40.3],
...   'lon': [-105.0, -105.0, -105.0]
... })

>>> df['displacement'] = df.xyz.ds_from_xy()
>>> df['displacement']
0        0.000000
1    11119.492664
2    22238.985329
dtype: float64

>>> df.xyz.s_from_ds()
0        0.000000
1    11119.492664
2    33358.477993
dtype: float64

Dependencies and Installation

Pandas, NumPy, and SciPy are required.

The package is available on PyPi and can be installed with pip:

$ pip install pandas-xyz

License

License

This project is licensed under the MIT License. See LICENSE file for details.

Documentation

The official documentation is hosted at readthedocs: https://pandas-xyz.readthedocs.io/en/stable/

The Elevation Smoothing Algorithm

The algorithm I apply to filter elevation time series is based on a paper produced by the National Renewable Energy Laboratory. Their algorithm is meant to smooth the elevation time series of a moving vehicle for more reasonable estimates of road grades for energy consumption models. This actually isn't that different from my end goal of smoothing elevation series for more reasonable estimates of elevation gain and energy consumption by ambulating humans! The paper is included in the resources folder

Project Status

Complete

  • Implement an algorithm to smooth noisy elevation time series.
  • Implement a smoothing algorithm for elevation series as a function of distance (similar to how the completed time-smoother works.)

Current Activities

  • Implement an algorithm to smooth GPS position and speed data. Most GPS-enabled activity trackers filter their speed and distance timeseries to remove measurement noise. I want to try and figure out how they do it, then replicate their techniques, and compare the smoothed position data.
  • Develop and document a variety of elevation gain/loss algorithms.
  • Describe the algorithms in more detail. Maybe in a wiki?
  • Provide references to papers and other resources where I got inspiration for each algorithm.

Future Work

  • Benchmark algorithm performance (speed, accuracy, and consistency):
    • Generate dummy time series of (distance, elevation) data to check smoothing algorithm.
    • Generate series of GPS points to obtain elevation coordinates from various DEMs (using elevation-query package) to compare elevation datasets with and without smoothing.
  • Create gain/loss algorithms to emulate those employed by Strava / TrainingPeaks / Garmin.

Contact

Reach out to me at one of the following places!

About

Geospatial calculation accessor for pandas DataFrames

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published