Skip to main content

Python package for manipulating gpx files and easily convert gpx to other different formats.

Project description

https://img.shields.io/pypi/v/gpx_converter.svg https://img.shields.io/travis/nidhaloff/gpx_converter.svg Documentation Status PyPI - Wheel PyPI - Downloads PyPI - License GitHub last commit Twitter URL https://img.shields.io/badge/$-buy%20me%20a%20coffee-ff69b4.svg?style=social

GPX manipulation for humans

Python package for manipulating gpx files and easily convert gpx to other different formats.

When & Why

  • You need to convert GPX to other formats

  • You need to convert other formats like csv to GPX

  • You want to interpolate the GPX coordinates

  • High level of abstraction

  • Stable API

  • easy to use and to extend

Motivation

I decided to create this project because I had gpx data that I needed to manipulate. I searched for a python package for this but I did not find what I was looking for, therefore I created the gpx-converter package to make gpx files manipulation very easy. Furthermore, the package contains methods for applying interpolation on the gpx data. This feature was very helpful for me since I also needed to interpolate the gpx data and convert it to csv. Feel free to contribute or to give me feedback anytime :)

Features

  • Convert gpx files to other formats such as csv, numpy arrays, dataframes, excel and json

  • Convert csv files to gpx

  • Apply interpolation on the gpx data

Installation

$ pip install gpx_converter

Quick Usage

from gpx_converter import Converter

Just read the gpx to dictionary

dic = Converter(input_file='your_input.gpx').gpx_to_dictionary(latitude_key='latitude', longitude_key='longitude')
# now you have a dictionary and can access the longitudes and latitudes values from the keys
latitudes = dic['latitude']
longitudes = dic['longitude']

Convert GPX to other formats

  • Convert from gpx to csv:

Converter(input_file='your_input.gpx').gpx_to_csv(output_file='your_output.csv')
  • Convert from gpx to excel sheets:

Converter(input_file='your_input.gpx').gpx_to_excel(output_file='your_output.xlsx')
  • Convert from gpx to json:

Converter(input_file='your_input.gpx').gpx_to_json(output_file='your_output.json)
  • Convert gpx file to dataframe:

df = Converter(input_file='your_input.gpx').gpx_to_dataframe()
  • Convert gpx file to numpy array:

np_array = Converter(input_file='your_input.gpx').gpx_to_numpy_array()

Now convert other formats to GPX

  • csv to gpx

Converter(input_file='your_input.csv').csv_to_gpx(lats_colname=column_name_of_latitudes,
                                                 longs_colname=column_name_of_longitudes,
                                                 output_file='your_input.gpx')
  • excel to gpx

Converter(input_file='your_input.xlsx').excel_to_gpx(lats_colname=column_name_of_latitudes,
                                                 longs_colname=column_name_of_longitudes,
                                                 output_file='your_input.gpx')
  • dataframe to gpx (notice that the method is static)

Converter.dataframe_to_gpx(input_df=your_df,
                           lats_colname=column_name_of_latitudes,
                           longs_colname=column_name_of_longitudes,
                           output_file='your_input.gpx')
  • json to gpx

Converter(input_file='your_input.json').json_to_gpx(input_df=your_df,
                                                   lats_colname=column_name_of_latitudes,
                                                   longs_colname=column_name_of_longitudes,
                                                   output_file='your_input.gpx')
  • Automate the conversion of multiple csv file to gpx:

Converter.convert_multi_csv_to_gpx(dirpath='your_directory/')
  • Apply spline interpolation on gpx file (you need to install scipy for this to work):

interpolated_coordinates = Converter.spline_interpolation(cv=your_array_of_control_vertices)

Contributions

Feel free to give me feedback anytime or contact me if you find the package useful.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpx_converter-1.6.6.tar.gz (14.7 kB view hashes)

Uploaded Source

Built Distribution

gpx_converter-1.6.6-py2.py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page