I was looking for the same thing, but ultimately the GPX file is another XML file, so you can parse it with XML syntax libraries like Nokogiri . This is how I extract all latitudes and longitudes from the GPX log:
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::XML(open(my-log.gpx))
trackpoints = doc.xpath('//xmlns:trkpt/')
points = Array.new
trackpoints.each do |trkpt|
points << [trkpt.xpath('@lat').to_s.to_f, trkpt.xpath('@lon').to_s.to_f]
end
There are probably better ways to do this, but it works for me.
source
share