remisalmon / strava-local-heatmap Goto Github PK
View Code? Open in Web Editor NEWPython script to generate a high resolution heatmap from Strava GPX files
Home Page: https://git.io/fjXTL
License: MIT License
Python script to generate a high resolution heatmap from Strava GPX files
Home Page: https://git.io/fjXTL
License: MIT License
Hi
I have the following error reading some GPX file. I guess one GPX could be corrupted but it could be good that the program is more robust and walk over:
Reading activity_Afternoon_spring_walk_on_19_04_2021_22MWC2ctUdab3XyRBzGowTNJtTM.gpx
Reading activity_Afternoon_walk_in_the_βοΈon_28_02_2021_22MR1PQbnlYKSLZy3ZatOHsNev7.gpx
Traceback (most recent call last):
File "C:\temp\GPX\strava_local_heatmap.py", line 349, in
main(args)
File "C:\temp\GPX\strava_local_heatmap.py", line 123, in main
for line in file:
File "C:\Users**\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 433: character maps to
When using the year filter and at the end the script uses only about 500 tracks from over 15000 (1 year out of 10) my plotted heatmap is nearly completely black.
When calculating the strenght/glow/... when drawing the heatmap seems to work with the count of all files and not only filtered ones. So when taking into account all the tracks from all years the tracks from 2022 will only be a tiny part of them resulting in a nearly black image. But I am not able to find that place in the code.
Filtered by year 2022:
There are some red pixels in the original image. So it wants to show some data.
In addition to one folder containing all files on could create separate folders for each year .... but at he same time this would make the year filter obsolete.
If the file has one unique line, the program fail.
Problem is here:
with open(gpx_file) as file:
for line in file:
I really like the script and its output and would like to use it in more flexible ways. It currently expects the data to be in a flat directory full of GPX files. One can only take all files in that directory of specify a glob that matches them. I have a hierarchy of directories where I have like one for cycling, then one for different types of trips. I would like to have one heatmap with my shopping, my recreational tours, and so on. But then I want to have one one layer up with all the GPX files below, so basically */*.gpx
and *.gpx
. As one can only pass one glob, it doesn't work.
Ideally one could refactor the heatmap code into a library such that one can use that as part of a driver script. I see that there is a pull request that tries to introduces some part of this but uses the now outdated setup.py
mechanism instead of Poetry.
I'd be happy to refactor the code, but wanted to talk to you first. Are you still active with this code? Shall I go ahead and refactor, should I do a hard fork or something in between?
First: Great tool and thank you for your effort!
By importing GPX-tracks from my DJI drone I get in some trouble.
RuntimeWarning: invalid value encountered in true_divide
data = (data-data.min())/(data.max()-data.min()) # normalize to [0,1]
The heatmap is saved but without any tracks. I pinpointed the error to line 239f. It looks like the data array is not correctly assigned.
for i, j in ij_data:
data[i-sigma_pixel:i+sigma_pixel, j-sigma_pixel:j+sigma_pixel] += 1.0
At the end the data array contains only zeros.
I uploaded the gpx track here for debugging (just rename it to *.gpx):
DJIFlightRecord_2022-02-09_16-07-50.txt
I am ready to support, but at the moment I am not able to find the problem. ;-)
Thanks in advance.
nico
Hello,
I tried to process thousands of files but then I saw the memory growing growing and then the process get killed...
Is there a plan to may-be better manage memory when using lot of files?
Hello,
I'v been pulling my hairs on this for quite few days now and I'm struggling to find a simple way to have the output at a specific size with the route centered (i.e: 1080x1920, or 800x800..). Not sure if that's currently possible but would love advice on direction as the level of maths in it is a way beyond my understanding...
Merci
is it possible to add .fit files to this?
Wikimedia tile server is offline. I tried experimenting with others such as openstreetmap, for example like this:
OSM_TILE_SERVER = 'https://tile.openstreetmap.org/{}/{}/{}.png'
I can download these tiles manually, but for some reason, the generated output is still a big black background. There's no warnings or errors during run.
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.