Shell script to filter gpx tracks before uploading
Апублікавана карыстальнікам BitSchupser 22 Красавік 2011 на мове EnglishI wrote a little shell script that processes various gpsbabel filters on gpx files, perhaps it is usefull for somewone else.
The following filters will be used:
- remove any trackpoints in the neighbourhood of your home (for privacy, do not forget to enter your position, lat= and lon=) (if you want to filter more regions you can duplicate the radius,distance line)
- remove any trackpoints that have a distance < 2 meters
- remove duplicate trackpoints
- simplify the track (removes unnecessary trackpoints)
- remove trackpoints with a hdop > 4
Here is the script:
#!/bin/sh
if [ -z "$1" -o -z "$2" ]; then
echo "usage: $0 infile outfile"
exit 1
fi
tmpfile=$(mktemp)
gpsbabel -i gpx -f "$1" \
-x transform,wpt=trk,del \
-x radius,distance=0.8K,lat=48,lon=11,nosort,exclude \
-x transform,trk=wpt,del \
-x duplicate,location \
-x position,distance=2m \
-x simplify,crosstrack,error=0.001k \
-x discard,hdop=4 \
-o gpx -F "$tmpfile"
# removes some crap gpsbabel added to the file
sed '/^.*<name>.*$/d' "$tmpfile" | sed '/^.*<cmt>.*$/d' | sed '/^.*<desc>.*$/d' > $2
rm $tmpfile