fit2gpx


Namefit2gpx JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://github.com/dodo-saba/fit2gpx
SummaryPackage to convert .FIT files to .GPX files, including tools for .FIT files downloaded from Strava
upload_time2022-12-29 14:17:33
maintainer
docs_urlNone
authorDorian Sabathier
requires_python>=3.6
licenseGNU AGPLv3
keywords convert .fit fit .gpx gpx strava
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/) [![Documentation Status](https://readthedocs.org/projects/fit2gpx/badge/?version=latest)](https://fit2gpx.readthedocs.io/en/latest/?badge=latest) [![GitHub license](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

# fit2gpx -- convert .fit to .gpx
This is a simple Python library for converting .FIT files to .GPX files. It also includes tools to convert Strava data downloads in bulk to GPX.
- [FIT](https://developer.garmin.com/fit/overview/) is a GIS data file format used by Garmin GPS sport devices and Garmin software
- [GPX](https://docs.fileformat.com/gis/gpx/) is an XML based format for GPS tracks.

# When: Use Cases
1. You need to convert .FIT files to pandas dataframe (e.g. for data analysis)
2. You need to convert .FIT files to .GPX
3. You need to fix files downloaded from Strava by converting the raw .FIT files to their .GPX counterparts

# Why
#### Motivation
I decided to create this package after spending a few hours searching for a simple solution to quickly convert hundreds of FIT files to GPX. I needed to do this as GIS applications do not parse FIT files. Whilst a few solutions existed, they are command line scripts which offered very little flexibility.

#### Relevance to Strava
- Pre-GPDR, you could bulk export all your Strava activities as GPX files.
- Post-GDPR, you can export an archive of your account. Whilst this includes much more data, activity GPS files are now downloaded in their original file format (eg. GPX or FIT format, some gzipped, some not) and named like 2500155647.gpx, 2500155647.gpx.gz, 2500155647.fit,  and 2500155647.fit.gz. 
- [How to bulk export you Strava Data](https://support.strava.com/hc/en-us/articles/216918437-Exporting-your-Data-and-Bulk-Export#Bulk)

# Overview
The fit2gpx module provides two converter classes: 
- Converter: used to convert a single or multiple FIT files to pandas dataframes or GPX files
- StravaConverter: used to fix all the Strava Bulk Export problems in three steps:
    1. Unzip GPX and FIT files
    2. Add activity metadata to existing GPX files
    3. Convert FIT files to GPX including activity metadata from Strava)

# Use Case 1: FIT to pd.DataFrame
Step 1: Import module and create converter object
```python
from fit2gpx import Converter

conv = Converter()
```
Step 2: Convert FIT file to 2 pd.DataFrame: fit_to_dataframes()
```python
df_lap, df_point = conv.fit_to_dataframes(fname='3323369944.fit')
```
- df_laps: information per lap: lap number, start time, total distance, total elapsed time, max speed, max heart rate, average heart rate
- df_points: information per track point: longitude, latitude, altitude, timestamp, heart rate, cadence, speed, power, temperature
  - Note the 'enhanced_speed' and 'enhanced_altitude' are also extracted. Where overlap exists with their default counterparts, values are identical. However, the default or enhanced speed/altitude fields may be empty  depending on the device used to record ([detailed information](https://pkg.go.dev/github.com/tormoder/fit#RecordMsg)).

    
# Use Case 2: FIT to GPX
Import module and create converter object
```python
from fit2gpx import Converter

conv = Converter()          # create standard converter object
```
Use case 2.1: convert a single FIT file: fit_to_gpx()
```python
gpx = conv.fit_to_gpx(f_in='3323369944.fit', f_out='3323369944.gpx')
```

Use case 2.2: convert many FIT files to GPX files: fit_to_gpx_bulk()
```python
conv.fit_to_gpx_bulk(dir_in='./project/activities/', dir_out='./project/activities_convert/')
```

# Use Case 3: Strava Bulk Export Tools (FIT to GPX conversion)
Copy the below code, adjusting the input directory (DIR_STRAVA), to fix the Strava Bulk Export problems discussed in the [overview](#Overview).
```python
from fit2gpx import StravaConverter

DIR_STRAVA = 'C:/Users/dorian-saba/Documents/Strava/'

# Step 1: Create StravaConverter object 
# - Note: the dir_in must be the path to the central unzipped Strava bulk export folder 
# - Note: You can specify the dir_out if you wish. By default it is set to 'activities_gpx', which will be created in main Strava folder specified.

strava_conv = StravaConverter(
    dir_in=DIR_STRAVA
)

# Step 2: Unzip the zipped files
strava_conv.unzip_activities()

# Step 3: Add metadata to existing GPX files
strava_conv.add_metadata_to_gpx()

# Step 4: Convert FIT to GPX
strava_conv.strava_fit_to_gpx()
```

# Dependencies
#### pandas
[pandas](https://github.com/pandas-dev/pandas) is a Python package that provides fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive.
#### gpxpy
[gpxpy](https://github.com/tkrajina/gpxpy) is a simple Python library for parsing and manipulating GPX files. It can parse and generate GPX 1.0 and 1.1 files. The generated file will always be a valid XML document, but it may not be (strictly speaking) a valid GPX document. 
#### fitdecode
[fitdecode](https://github.com/polyvertex/fitdecode) is a rewrite of the [fitparse](https://github.com/dtcooper/python-fitparse) module allowing to parse ANT/GARMIN FIT files.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dodo-saba/fit2gpx",
    "name": "fit2gpx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "convert,.fit,fit,.gpx,gpx,strava",
    "author": "Dorian Sabathier",
    "author_email": "dorian.sabathier+PyPi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/07/c0/4bd628aa7d925794607fa168babafbe1a5ed866da6ec64e2ce0322faf54c/fit2gpx-0.0.7.tar.gz",
    "platform": null,
    "description": "[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/) [![Documentation Status](https://readthedocs.org/projects/fit2gpx/badge/?version=latest)](https://fit2gpx.readthedocs.io/en/latest/?badge=latest) [![GitHub license](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n# fit2gpx -- convert .fit to .gpx\nThis is a simple Python library for converting .FIT files to .GPX files. It also includes tools to convert Strava data downloads in bulk to GPX.\n- [FIT](https://developer.garmin.com/fit/overview/) is a GIS data file format used by Garmin GPS sport devices and Garmin software\n- [GPX](https://docs.fileformat.com/gis/gpx/) is an XML based format for GPS tracks.\n\n# When: Use Cases\n1. You need to convert .FIT files to pandas dataframe (e.g. for data analysis)\n2. You need to convert .FIT files to .GPX\n3. You need to fix files downloaded from Strava by converting the raw .FIT files to their .GPX counterparts\n\n# Why\n#### Motivation\nI decided to create this package after spending a few hours searching for a simple solution to quickly convert hundreds of FIT files to GPX. I needed to do this as GIS applications do not parse FIT files. Whilst a few solutions existed, they are command line scripts which offered very little flexibility.\n\n#### Relevance to Strava\n- Pre-GPDR, you could bulk export all your Strava activities as GPX files.\n- Post-GDPR, you can export an archive of your account. Whilst this includes much more data, activity GPS files are now downloaded in their original file format (eg. GPX or FIT format, some gzipped, some not) and named like 2500155647.gpx, 2500155647.gpx.gz, 2500155647.fit,  and 2500155647.fit.gz. \n- [How to bulk export you Strava Data](https://support.strava.com/hc/en-us/articles/216918437-Exporting-your-Data-and-Bulk-Export#Bulk)\n\n# Overview\nThe fit2gpx module provides two converter classes: \n- Converter: used to convert a single or multiple FIT files to pandas dataframes or GPX files\n- StravaConverter: used to fix all the Strava Bulk Export problems in three steps:\n    1. Unzip GPX and FIT files\n    2. Add activity metadata to existing GPX files\n    3. Convert FIT files to GPX including activity metadata from Strava)\n\n# Use Case 1: FIT to pd.DataFrame\nStep 1: Import module and create converter object\n```python\nfrom fit2gpx import Converter\n\nconv = Converter()\n```\nStep 2: Convert FIT file to 2 pd.DataFrame: fit_to_dataframes()\n```python\ndf_lap, df_point = conv.fit_to_dataframes(fname='3323369944.fit')\n```\n- df_laps: information per lap: lap number, start time, total distance, total elapsed time, max speed, max heart rate, average heart rate\n- df_points: information per track point: longitude, latitude, altitude, timestamp, heart rate, cadence, speed, power, temperature\n  - Note the 'enhanced_speed' and 'enhanced_altitude' are also extracted. Where overlap exists with their default counterparts, values are identical. However, the default or enhanced speed/altitude fields may be empty  depending on the device used to record ([detailed information](https://pkg.go.dev/github.com/tormoder/fit#RecordMsg)).\n\n    \n# Use Case 2: FIT to GPX\nImport module and create converter object\n```python\nfrom fit2gpx import Converter\n\nconv = Converter()          # create standard converter object\n```\nUse case 2.1: convert a single FIT file: fit_to_gpx()\n```python\ngpx = conv.fit_to_gpx(f_in='3323369944.fit', f_out='3323369944.gpx')\n```\n\nUse case 2.2: convert many FIT files to GPX files: fit_to_gpx_bulk()\n```python\nconv.fit_to_gpx_bulk(dir_in='./project/activities/', dir_out='./project/activities_convert/')\n```\n\n# Use Case 3: Strava Bulk Export Tools (FIT to GPX conversion)\nCopy the below code, adjusting the input directory (DIR_STRAVA), to fix the Strava Bulk Export problems discussed in the [overview](#Overview).\n```python\nfrom fit2gpx import StravaConverter\n\nDIR_STRAVA = 'C:/Users/dorian-saba/Documents/Strava/'\n\n# Step 1: Create StravaConverter object \n# - Note: the dir_in must be the path to the central unzipped Strava bulk export folder \n# - Note: You can specify the dir_out if you wish. By default it is set to 'activities_gpx', which will be created in main Strava folder specified.\n\nstrava_conv = StravaConverter(\n    dir_in=DIR_STRAVA\n)\n\n# Step 2: Unzip the zipped files\nstrava_conv.unzip_activities()\n\n# Step 3: Add metadata to existing GPX files\nstrava_conv.add_metadata_to_gpx()\n\n# Step 4: Convert FIT to GPX\nstrava_conv.strava_fit_to_gpx()\n```\n\n# Dependencies\n#### pandas\n[pandas](https://github.com/pandas-dev/pandas) is a Python package that provides fast, flexible, and expressive data structures designed to make working with \"relational\" or \"labeled\" data both easy and intuitive.\n#### gpxpy\n[gpxpy](https://github.com/tkrajina/gpxpy) is a simple Python library for parsing and manipulating GPX files. It can parse and generate GPX 1.0 and 1.1 files. The generated file will always be a valid XML document, but it may not be (strictly speaking) a valid GPX document. \n#### fitdecode\n[fitdecode](https://github.com/polyvertex/fitdecode) is a rewrite of the [fitparse](https://github.com/dtcooper/python-fitparse) module allowing to parse ANT/GARMIN FIT files.",
    "bugtrack_url": null,
    "license": "GNU AGPLv3",
    "summary": "Package to convert .FIT files to .GPX files, including tools for .FIT files downloaded from Strava",
    "version": "0.0.7",
    "split_keywords": [
        "convert",
        ".fit",
        "fit",
        ".gpx",
        "gpx",
        "strava"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "f05a78763e0f8f8810f297f353046e38",
                "sha256": "b487ae73da147308c4fb9dc279cacf6e57ef1ddb32127d369108df032c83b7e1"
            },
            "downloads": -1,
            "filename": "fit2gpx-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "f05a78763e0f8f8810f297f353046e38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9886,
            "upload_time": "2022-12-29T14:17:33",
            "upload_time_iso_8601": "2022-12-29T14:17:33.361230Z",
            "url": "https://files.pythonhosted.org/packages/07/c0/4bd628aa7d925794607fa168babafbe1a5ed866da6ec64e2ce0322faf54c/fit2gpx-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-29 14:17:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dodo-saba",
    "github_project": "fit2gpx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fit2gpx"
}
        
Elapsed time: 0.07972s