[GIS] Create GPS (gpx) routes from GeoPandas geodataframe

geopandasgpspandaspython

I have a GeoPandas geodataframe with LineString geometries and I'd like to export them into .gpx files as GPS routes.

I've searched for hints in the web but found anything useful.

Are there GeoPandas specific way to do this or from other packages like Shapely?

Best Answer

To test my approach, I loaded a shapefile as GeoPandas geodataframe and, afterwards, I saved it as gpx file. This is the code:

import geopandas as gpd

lines = gpd.read_file('/home/zeito/pyqgis_data/my_lines.shp')

lines.to_file('/home/zeito/pyqgis_data/my_lines.gpx', 'GPX')

When gpx layer is loaded at Map Canvas, it could be observed that it works perfectly.

enter image description here