Coder Social home page Coder Social logo

kvenable2011 / gpx_converter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nidhaloff/gpx-converter

0.0 0.0 0.0 88 KB

python package for manipulating gpx files and easily converting gpx to other different formats

License: MIT License

Makefile 12.74% Python 87.26%

gpx_converter's Introduction

gpx_converter

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_output.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_output.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_output.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_output.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)

Usage from terminal

Alternatively you can use the gpx_converter directly from terminal. You just need to pass the function, input file and output file as arguments.

  • function: the conversion method you want to use. For example "gpx_to_csv"
  • input file: path to your input file
  • output file: path to your output file
$ gpx_converter --function "gpx_to_csv" --input_file "home/your_input.gpx" --output_file "home/your_output.csv"

or maybe you prefer the short version

$ gpx_converter -func "gpx_to_csv" -in "home/your_input.gpx" -out "home/your_output.csv"

Links

Check this article to know more about gpx files and how to use the gpx-converter package. https://medium.com/p/57da00bd36fc/edit

Contributions

Contributions are always welcome. Feel free to make a pull request. If you like the project or using it in daily life, consider giving me a feedback :)

gpx_converter's People

Contributors

nidhaloff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.