Skip to content

Commit

Permalink
#1 #6 Work in progress:
Browse files Browse the repository at this point in the history
-Update documentation to include conversion and saving methods
-Remove GPX.to_string method

[ci skip]
  • Loading branch information
FABallemand committed Sep 9, 2023
1 parent 6373ec3 commit 60c513a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
59 changes: 55 additions & 4 deletions doc/tutorials/writing.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Writing
-------
Converting and Saving
---------------------

Save as GPX file
^^^^^^^^^^^^^^^^

The :py:meth:`~to_gpx` allows to export a :py:class:`~ezgpx.gpx.GPX` object as a GPX file.
The :py:meth:`~to_gpx` allows to export a :py:class:`~ezgpx.gpx.GPX` object as a `GPX <https://en.wikipedia.org/wiki/GPS_Exchange_Format>`_ file.

::

Expand All @@ -16,4 +16,55 @@ The :py:meth:`~to_gpx` allows to export a :py:class:`~ezgpx.gpx.GPX` object as a
# Do stuff with GPX object

# Save as GPX file
gpx.to_gpx("new_file.gpx")
gpx.to_gpx("new_file.gpx")

Save as KML file
^^^^^^^^^^^^^^^^

The :py:meth:`~to_kml` allows to export a :py:class:`~ezgpx.gpx.GPX` object as a `KML <https://en.wikipedia.org/wiki/Keyhole_Markup_Language>`_ file.

::

from ezgpx import GPX

# Parse GPX file
gpx = GPX("file.gpx")

# Do stuff with GPX object

# Save as KML file
gpx.to_kml("new_file.kml")

Save as CSV file
^^^^^^^^^^^^^^^^

The :py:meth:`~to_csv` allows to export a :py:class:`~ezgpx.gpx.GPX` object as a `CSV <https://en.wikipedia.org/wiki/Comma-separated_values>`_ file.

::

from ezgpx import GPX

# Parse GPX file
gpx = GPX("file.gpx")

# Do stuff with GPX object

# Save as CSV file
gpx.to_csv("new_file.csv", columns=["lat", "lon", "ele"])

Convert to Pandas Dataframe
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The :py:meth:`~to_kml` allows to convert a :py:class:`~ezgpx.gpx.GPX` object as a `Pandas Dataframe <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_.

::

from ezgpx import GPX

# Parse GPX file
gpx = GPX("file.gpx")

# Do stuff with GPX object

# Convert to Pandas Dataframe
df = gpx.to_dataframe()
15 changes: 9 additions & 6 deletions examples/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# Parse GPX file
gpx = ezgpx.GPX("file.gpx")

# Convert to Pandas Dataframe
df = gpx.to_dataframe()
# Save as GPX file
gpx.to_gpx("new_file.gpx")

# Save as KML file
gpx.to_kml("new_file.kml")

# Convert to CSV
gpx.to_csv("file.csv", columns=["lat", "lon", "ele"])
# Save as CSV file
gpx.to_csv("new_file.csv", columns=["lat", "lon", "ele"])

# Convert to KML
gpx.to_kml("file.kml")
# Convert to Pandas Dataframe
df = gpx.to_dataframe()
2 changes: 1 addition & 1 deletion ezgpx/gpx/gpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def merge(self, gpx: GPX):
if self.gpx.extensions is None:
self.gpx.extensions = gpx.gpx.extensions

def to_string(self) -> str:
def to_gpx_string(self) -> str:
"""
Convert the GPX object to a string.
Expand Down
1 change: 1 addition & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [gpxpy](https://github.com/tkrajina/gpxpy)

## 📝 TO DO LIST !!
- Change to project.toml (https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html)
- Documentation for conversion + Medium
- Sub classes for GPX & KML writers
- Merge method
Expand Down

0 comments on commit 60c513a

Please sign in to comment.