% GPX to Matlab % Processes the .gpx files from the OSM dump to matlab geopoint format. % Author George Hilton email: g.hilton@soton.ac.uk % Date: 17/01/2017 clear all cd ('C:\Local\Traffic Data\Open Stret Map tracks\great_britain.tar\gpx-planet-2013-04-09\identifiable\001') % Assess top level directory folders = dir('C:\Local\Traffic Data\Open Stret Map tracks\great_britain.tar\gpx-planet-2013-04-09\identifiable\001'); % Remove current and parent directory markers to prevent infinite loop yg = ismember({folders.name},{'.','..'}); folders(yg) = []; % Create empty cell ready to populate with all files files = cell(length(folders)); % Iterate through folders in top level directory. Run dir() on each folder % in top level directory and assign to files array. for K = 1 : length(folders) thisdir = folders(K).name; files{K} = dir(thisdir); end % Iterate through all files within OSM dump for i = 10:length(files) % Prevent infinite loop yg = ismember({files{i,1}.name},{'.','..'}); files{i,1}(yg) = []; % Add path for each folder to enable gpxread function use. addpath(files{i,1}.folder) % Iterate throughall files in each folder for p = 1:length(files{i,1}) % Convert to matlab format and save fileName = files{i,1}(p).name; %A = gpxread(fileName); data = gpxread(fileName); str = sprintf('A_%d_%d',i,p); save(str,'data') end end