andersle / gpxplotter Goto Github PK
View Code? Open in Web Editor NEWgpxplotter reads gpx files and makes some simple plots.
License: Other
gpxplotter reads gpx files and makes some simple plots.
License: Other
sklearn
seems to be deprectaed. When I run pip install gpxplotter
this happens
Collecting sklearn (from gpxplotter)
Using cached sklearn-0.0.post9.tar.gz (3.6 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
rather than 'sklearn' for pip commands.
Here is how to fix this error in the main use cases:
- use 'pip install scikit-learn' rather than 'pip install sklearn'
- replace 'sklearn' by 'scikit-learn' in your pip requirements files
(requirements.txt, setup.py, setup.cfg, Pipfile, etc ...)
- if the 'sklearn' package is used by one of your dependencies,
it would be great if you take some time to track which package uses
'sklearn' instead of 'scikit-learn' and report it to their issue tracker
- as a last resort, set the environment variable
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error
More information is available at
https://github.com/scikit-learn/sklearn-pypi-package
If the previous advice does not cover your use case, feel free to report it at
https://github.com/scikit-learn/sklearn-pypi-package/issues/new
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
It seems changing sklearn
to scikit-learn
would fix this issue.
I am using gpx generated from the data of the owntracks program(android), which sends data via mqtt to my server.
The resulting gpx is normally torn off in any programs.
gpx has a minimal structure: coordinates and time.
If you take a piece of the track, it generates normally.
If I take a full track, I get an error:
lib/python3.6/site-packages/scipy/interpolate/fitpack2.py:253: UserWarning: The maximal number of iterations maxit (set to 20 by the program) allowed for finding a smoothing spline with fp=s has been reached: s too small. There is an approximation returned but the corresponding weighted sum of squared residuals does not satisfy the condition abs(fp-s)/s < tol. warnings.warn(message)
Data is transmitted every second for a total of 4700 points. ~ 79 minutes. With so many points, an error appears.
If I delete some points - 4660, then the graph is drawn.
The function approximate_velocity
in gpxread.py
may result into NaN error, when there is over one segment in one second.
The traceback information is provided below (some private information is omitted)
Traceback (most recent call last):
File "./plotgpx.py", line 16, in <module>
for track in read_gpx_file(the_file):
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/gpxplotter/gpxread.py", line 355, in read_gpx_file
process_segment(segment, max_heart_rate=max_heart_rate)
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/gpxplotter/gpxread.py", line 306, in process_segment
segment['velocity-level'] = cluster_velocities(segment['velocity'])
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/gpxplotter/common.py", line 190, in cluster_velocities
labels = clu.fit_predict(vel)
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/sklearn/cluster/_kmeans.py", line 1077, in fit_predict
return self.fit(X, sample_weight=sample_weight).labels_
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/sklearn/cluster/_kmeans.py", line 982, in fit
accept_large_sparse=False)
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/sklearn/base.py", line 421, in _validate_data
X = check_array(X, **check_params)
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/sklearn/utils/validation.py", line 63, in inner_f
return f(*args, **kwargs)
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/sklearn/utils/validation.py", line 721, in check_array
allow_nan=force_all_finite == 'allow-nan')
File "~/anaconda3/envs/gps/lib/python3.7/site-packages/sklearn/utils/validation.py", line 106, in _assert_all_finite
msg_dtype if msg_dtype is not None else X.dtype)
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
The reason may exist in too many duplicate entries in time : np.ndarray
when using scipy.interpolate.UnivariateSpline
.
So I use the following workaround (insert after gpxread.py#L250), and it works fine for my use case.
if np.isnan(spline(time)).any():
_rng = time.max() + 1
_distance = [0] * (_rng)
for i,val in enumerate(distance):
_distance[ time[i] ] += val
_time = np.array(range(_rng))
_distance = np.array(_distance)
spline = UnivariateSpline(_time, _distance, k=3)
I hope the maintainer could provide a more reliable fix asap, thanks!
Hello, I'm just getting started with gpxplotter and got the following error when trying to run one of the examples:
File "/lib/python3.11/site-packages/gpxplotter/__init__.py", line 40, in <module>
from .mplplotting import plot_line, plot_filled
File "/lib/python3.11/site-packages/gpxplotter/mplplotting.py", line 11, in <module>
from matplotlib.cm import get_cmap
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm' (/lib/python3.11/site-packages/matplotlib/cm.py)
Googling the error reveals that several packages using matplotlib have started experiencing this error after matplotlib 3.9.0 came out a few weeks ago. Downgrading matplotlib to the previous version (3.8.4) got rid of the error. Not sure if there's any way for gpxplotter to avoid this problem, other than advising users not to install matplotlib 3.9.0.
I'm looking at adapting this library to help me visualize my e-bike rides (where I'm engaging the motor, how much power I'm putting in vs. battery power, etc).
I'm curious if you've toyed with ipywidgets and folium at all. I'd like to create a visualization that allows you to hover over a chart (heart rate, power, altitude) and display the location of that sample on the map.
(Using Windows and Jupyter lab)
gpx_file = "example1.gpx"
from gpxplotter import read_gpx_file, create_folium_map, add_segment_to_map
line_options = {'weight': 8}the_map = create_folium_map(tiles='openstreetmap')
for track in read_gpx_file(gpx_file):
for i, segment in enumerate(track['segments']):
add_segment_to_map(the_map, segment, color_by='velocity-level',
cmap='RdPu_09', line_options=line_options)
It worked fine.
ValueError Traceback (most recent call last)
Input In [4], in <cell line: 5>()
2 line_options = {'weight': 8}
4 the_map = create_folium_map(tiles='openstreetmap')
----> 5 for track in read_gpx_file(gpx_file):
6 for i, segment in enumerate(track['segments']):
7 add_segment_to_map(the_map, segment, color_by='velocity-level',
8 cmap='RdPu_09', line_options=line_options)File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\gpxplotter\gpxread.py:352, in read_gpx_file(gpxfile, max_heart_rate)
335 def read_gpx_file(gpxfile, max_heart_rate=187):
336 """Read data from a given gpx file.
337
338 Parameters
(...)
350
351 """
--> 352 gpx = minidom.parse(gpxfile)
353 tracks = gpx.getElementsByTagName('trk')
354 for track in tracks:File ~\AppData\Local\Programs\Python\Python310\lib\xml\dom\minidom.py:1988, in parse(file, parser, bufsize)
1986 if parser is None and not bufsize:
1987 from xml.dom import expatbuilder
-> 1988 return expatbuilder.parse(file)
1989 else:
1990 from xml.dom import pulldomFile ~\AppData\Local\Programs\Python\Python310\lib\xml\dom\expatbuilder.py:913, in parse(file, namespaces)
911 result = builder.parseFile(fp)
912 else:
--> 913 result = builder.parseFile(file)
914 return resultFile ~\AppData\Local\Programs\Python\Python310\lib\xml\dom\expatbuilder.py:204, in ExpatBuilder.parseFile(self, file)
202 try:
203 while 1:
--> 204 buffer = file.read(16*1024)
205 if not buffer:
206 breakValueError: I/O operation on closed file.
The "Simple example for showing a track in a map, colored by heart rate" demo fails to run on my gpx file (exported from Garmin Connect), with the following error:
Traceback (most recent call last):
File "b.py", line 10, in
save_map(fig, 'test-{}.html'.format(i))
File "C:\Program Files\Python37\lib\site-packages\gpxplotter\mplplotting.py", line 420, in save_map
mplleaflet.show(path=name, fig=fig, tiles=tile)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet_display.py", line 180, in show
save_html(fig, fileobj=f, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet_display.py", line 131, in save_html
html = fig_to_html(fig, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet_display.py", line 84, in fig_to_html
exporter.run(fig)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 51, in run
self.crawl_fig(fig)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 118, in crawl_fig
self.crawl_ax(ax)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 123, in crawl_ax
props=utils.get_axes_properties(ax)):
File "C:\Program Files\Python37\lib\site-packages\mplleaflet\mplexporter\utils.py", line 267, in get_axes_properties
'axes': [get_axis_properties(ax.xaxis),
File "C:\Program Files\Python37\lib\site-packages\mplleaflet\mplexporter\utils.py", line 231, in get_axis_properties
props['grid'] = get_grid_style(axis)
File "C:\Program Files\Python37\lib\site-packages\mplleaflet\mplexporter\utils.py", line 241, in get_grid_style
if axis._gridOnMajor and len(gridlines) > 0:
AttributeError: 'XAxis' object has no attribute '_gridOnMajor'
I tried your script on some files I downloaded from Garmin but the scripts seem to have a date parsing problem:
Traceback (most recent call last):
File "garmin-plotter.py", line 6, in <module>
for track in read_gpx_file(file_name, maxpulse=187):
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 283, in read_gpx_file
'segments': [read_segment(i, maxpulse=maxpulse) for i in segments],
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 283, in <listcomp>
'segments': [read_segment(i, maxpulse=maxpulse) for i in segments],
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 172, in read_segment
data = get_point_data(point)
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 142, in get_point_data
time = extract_data(point, 'time', date_format)
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 121, in extract_data
return [formatter(child.data) for child in i.childNodes]
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 121, in <listcomp>
return [formatter(child.data) for child in i.childNodes]
File "C:\Users\Daniel\Anaconda3\lib\site-packages\gpxplotter\gpxread.py", line 139, in date_format
timeobj = datetime.strptime(string, '%Y-%m-%dT%H:%M:%S.%f%z')
File "C:\Users\Daniel\Anaconda3\lib\_strptime.py", line 565, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "C:\Users\Daniel\Anaconda3\lib\_strptime.py", line 362, in _strptime
(data_string, format))
ValueError: time data '2019-10-02T11:11:44.000Z' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'
I suspect the problem is that it expects a lowercase z at the end, when the files have uppercase Z. I believe uppercase Z is also the most common (maybe only allowed) format for UTC.
trying to plot a gpx file generated by a garmin GPSMAP 65s
I'm getting the error:
Traceback (most recent call last):
File "gpxread.py", line 6, in
for track in read_gpx_file('day1.gpx'):
File "C:\USERS\me\Anaconda3\envs\gpx\lib\site-packages\gpxplotter\gpxread.py", line 345, in read_gpx_file
process_segment(segment, max_heart_rate=max_heart_rate)
File "C:\USERS\me\Anaconda3\envs\gpx\lib\site-packages\gpxplotter\gpxread.py", line 286, in process_segment
segment['velocity'] = approximate_velocity(
File "C:\USERS\me\Anaconda3\envs\gpx\lib\site-packages\gpxplotter\gpxread.py", line 250, in approximate_velocity
spline = UnivariateSpline(time, distance, k=3)
File "C:\USERS\me\Anaconda3\envs\gpx\lib\site-packages\scipy\interpolate\fitpack2.py", line 202, in init
data = dfitpack.fpcurf0(x, y, k, w=w, xb=bbox[0],
dfitpack.error: (m>k) failed for hidden m: fpcurf0:m=3
This is my code
from gpxplotter import read_gpx_file, create_folium_map, add_segment_to_map
my_map = create_folium_map(tiles='kartverket_topo4')
line_options = {'color': 'red', 'weight': 8, 'opacity': 0.5}
for track in read_gpx_file('day1.gpx'):
for i, segment in enumerate(track['segments']):
add_segment_to_map(my_map, segment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.