Code covered by the BSD License  

Highlights from
GPX file reader

4.4

4.4 | 7 ratings Rate this file 61 Downloads (last 30 days) File Size: 2.73 KB File ID: #24154
image thumbnail

GPX file reader

by

 

%LOADGPX Loads route points from a GPS interchange file

| Watch this File

File Information
Description

% ROUTE = LOADGPX(FILENAME) Loads route point information from a .GPX
% GPS interchange file. This utility is not a general-purpose
% implementation of GPX reading and is intended mostly for reading the
% files output by the "gmap pedometer" tool.
%
% ROUTE is a Nx6 array where each row is a route point.
% Columns 1-3 are the X, Y, and Z coordinates.
% Columns 4-5 are latitude and longitude
% Column 6 is cumulative route length.
%
% Note that the mapping of latitude/longitude assumes an approximate spherical
% transformation to rectangular coordinates.
%
% Additional property/value arguments:
% LOADGPX(...,'ElevationUnits','meters',...) uses meters for elevation
% LOADGPX(...,'Viz',true,...) displays the route and elevation map
%
% For more information on the gmap pedometer and GPX output:
% http://www.gmap-pedometer.com/
% http://www.elsewhere.org/journal/gmaptogpx/
%
% See also xmlread

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
24 Apr 2012 Fran├žois Janod

sorry, I forgot this line, to put before the switch line:

lat_mean=mean(route(:,COL_LAT));

24 Apr 2012 Fran├žois Janod

Useful contribution, but mistakenly computed for meter units. should be like that:
KM_PER_ARCMINUTE = 1.852;
route(:,COL_X:COL_Y) = KM_PER_ARCMINUTE*1000*60*route(:,COL_X:COL_Y);

and forget to take into account latitude. must add this line:
route(:,COL_X) = route(:,COL_X)*cos(lat_mean/180*pi);

all in all should be like that:

case 'feet'
MILES_PER_ARCMINUTE = 1.15;
route(:,COL_X:COL_Y) = MILES_PER_ARCMINUTE*5280*60*route(:,COL_X:COL_Y);
route(:,COL_X) = route(:,COL_X)*cos(lat_mean/180*pi); %correction de latitude
distMult = 1/5280; %5280 feets = 1 Mile
case 'meters'
KM_PER_ARCMINUTE = 1.852;
route(:,COL_X:COL_Y) = KM_PER_ARCMINUTE*1000*60*route(:,COL_X:COL_Y);
route(:,COL_X) = route(:,COL_X)*cos(lat_mean/180*pi);
distMult = 1/1000;

14 Mar 2012 Bernd

very helpful...but I also had to impement the changes from Georg. please think about updating the file

02 Sep 2011 Evan

Can't figure out the units of the X, Y, and Z columns. I did the same as George to get gpx files with trkpt instead of rtept. Also converted time to Matlab serial time using datenum.

09 May 2011 Georg Ogris

To read my Garmin data change

ptList = d.getElementsByTagName('rtept');
into
ptList = d.getElementsByTagName('trkpt');

and add:

tim = pt.getElementsByTagName('time') ;
timChar = char(tim.item(0).getTextContent) ;
route(i,COL_TIMEVEC) = datevec([timChar(1:10) ' ' timChar(12:19)]) ;

before the end of the main for-loop
with

COL_TIMEVEC = 7:12;

09 May 2011 Georg Ogris  
26 Jul 2010 David Longin  
14 Jan 2010 Andrew Bliss

This is a useful, good file. A few adjustments could improve it.

To allow the output, 1st line should be:
function route=loadgpx(fileName,varargin)

Calculate range before the viz section, so it can be output too if the viz option is off.

Something about the units is off but I didn't take the time to figure out what is wrong with it... gmaptogpx is outputting elevations in meters, right?

Thanks!

14 Jan 2010 Andrew Bliss  

Contact us