<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>notes from Ken &#187; GPS</title>
	<atom:link href="http://www.notes.xythian.net/category/programming/gps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.notes.xythian.net</link>
	<description>Links, technical notes, whatnot.</description>
	<lastBuildDate>Sun, 04 Jul 2010 19:01:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>GPX to line overlaid atop USGS Urban Area photo</title>
		<link>http://www.notes.xythian.net/2006/03/03/gpx-to-line-overlaid-atop-usgs-urban-area-photo/</link>
		<comments>http://www.notes.xythian.net/2006/03/03/gpx-to-line-overlaid-atop-usgs-urban-area-photo/#comments</comments>
		<pubDate>Sat, 04 Mar 2006 02:13:44 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[GPS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.notes.xythian.net/2006/03/03/gpx-to-line-overlaid-atop-usgs-urban-area-photo/</guid>
		<description><![CDATA[The other day I wrote about a script to simplify GPS plots for plotting polylines using Google Maps. The momentum from that finally propelled me to learn enough about this stuff to be able to have the script output this: (The inlined image is resized to fit into my WordPress layout, it links to the [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I wrote about a script to <a href="http://www.notes.xythian.net/2006/02/28/simplifying-gps-data-to-plot-polylines/">simplify GPS plots</a> for plotting polylines using Google Maps.</p>
<p>The momentum from that finally propelled me to learn enough about this stuff to be able to have the script output this:</p>
<p><a href="http://xythian.net/2006/03/02/skate.jpg"><img src="http://xythian.net/2006/03/02/skate-web.jpg" width="400" height="408"/></a></p>
<p>(The inlined image is resized to fit into my WordPress layout, it links to the full image.  I also rendered using the <a href="http://xythian.net/2006/03/02/skate-topo.jpg">topographic map</a> tile set.)</p>
<p>This is a 4 meters/pixel resolution render of the same track used in the previous post to TerraServer-served USGS Urban Area photos.   To make it, the script:</p>
<ol>
<li>Parse the GPX file into lat/long (same as it did before</li>
<li>Convert all the lat/long points to <a href="http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system">Universal Transverse Mercator</a> (UTM) points &#8212; this is a convenient coordinate system, particularly since it is what TerraServer uses..</li>
<li>Compute the TerraServer image tiles corrosponding to the UTM coordinates covered by the track.   This is straightforward division.   Since I wanted 4mpp resolution, I used Scale 12 when hitting the <a href="http://terraserver-usa.com/About/AboutLinktoHtml.htm">TerraServer tile URL</a>.   This meant converting to TerraServer tiles is just &#8220;divide by 800&#8243;</li>
<li>Fetch all the tiles and assemble them into an image (the script caches the tiles it fetches so repeated runs covering the same geographic area are fast)</li>
<li>Plot the track over the map</li>
</ol>
<p><a href="http://pygps.org/">pygps.org</a> was a big help here, for both the LatLongUTMconversion library and the source code to the mapviewer, which clued me into the easy way to fetch TerraServer tiles.   I had spent quality time browsing the TerraServer SOAP documentation, but never quite got a SOAP implementation for Python to work.</p>
<p>I modified the LatLongUTMconversion library to work with Numeric Python arrays.</p>
<p>UTM is also convenient because it dispenses with lots of messy distance-on-sphere distance calculations to figure out the distances between points &#8212; UTM coordinates are in meters and use a square grid.   So I can use the usual Cartesian distance calculation for distances.    My code is probably little dodgy on UTM zone boundaries but fortunately I have no tracks that cross a zone boundary so I can put off dealing with that for the time being.</p>
<p>The track shown there is also interpolated using a spline.   I dug the code for splines out of ancient C++ code I wrote back in the last millenium for a college independent study.    After I converted it to Python, it fit into my script and worked.   The track is smoother and most of it looks better but it behaves badly in some cases.</p>
<p>I need to do some (more) research about how this works so I can improve it.   <a href="http://www.topofusion.com/spline.php">Topofusion</a> does what I want, I just need to learn how it works.    TopoFusion is a great app &#8212; it&#8217;s what I actually use to manage to look at most of my GPS tracks.   Working on this script is about learning about mapping and visualizing rather than addressing some problem with TopoFusion.</p>
<p>Making this all work has been educational.    Most of what I&#8217;ve done I could use USGS DOQ and DRG files rather than TerraServer as a map/photo image source.    TerraServer is very convenient, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.notes.xythian.net/2006/03/03/gpx-to-line-overlaid-atop-usgs-urban-area-photo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simplifying GPS data to plot polylines</title>
		<link>http://www.notes.xythian.net/2006/02/28/simplifying-gps-data-to-plot-polylines/</link>
		<comments>http://www.notes.xythian.net/2006/02/28/simplifying-gps-data-to-plot-polylines/#comments</comments>
		<pubDate>Tue, 28 Feb 2006 08:44:52 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[GPS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.notes.xythian.net/2006/02/28/simplifying-gps-data-to-plot-polylines/</guid>
		<description><![CDATA[I was reading Ryan&#8217;s post about Google Maps and could not resist hacking together a relatively simpleminded track simplifying script. It reads a GPX file and prints out the JavaScript necessary to plot the track using the Google Maps API. Its use of the Google Maps API is pretty simpleminded (it just centers on the [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading <a href="http://unclehulka.com/ryan/blog/archives/2006/02/27/maps-hacking-volume-2/">Ryan&#8217;s post about Google Maps</a> and could not resist hacking together a relatively simpleminded track simplifying script.</p>
<p>It reads a GPX file and prints out the JavaScript necessary to plot the track using the Google Maps API.</p>
<p>Its use of the Google Maps API is pretty simpleminded (it just centers on the begin point at a fixed zoom level), as is its parsing of the GPX file (it assumes there&#8217;s only one track in it and there&#8217;s no error checking).</p>
<p>I hurried past those bits so I could see if my idea worked on a skate GPS track.  It seems to.  It reduced my 225 point sample track to 28 points and looks roughly right when I zoom into gmaps.   One could adjust EPISILON for more or less simplifcation.  A more sophisticated script could use a more clever mechanism for fitting a path onto the GPS points and then use the minimal number of points to plot the track.    My mechansim assumes you want to preserve speed data with the points (though it doesn&#8217;t actually use it for anything) &#8212; in case you want to show something when there&#8217;s a big change in velocity.</p>
<p>A Span has a begin, end, and a time.   A Span can be extended to a new end point iff the new endpoint is close (as defined by EPISILON) to where the extrapolated location would be from the old end point + the velocity implied by the Span would be. </p>
<p>Here&#8217;s the <a href="http://xythian.net/2006/02/28/gmaptest.html">map</a>.  It&#8217;s a bit rough in spots, but so is the GPS plot.   An EVEN MORE sophisticated version of this could know where the roads/trails are and fix the track accordingly.</p>
<p>Here&#8217;s the script: <a href="http://xythian.net/2006/02/28/gpx2polyline.script">gpx2polyline.py</a></p>
<p>The script requires numpy (rather gratutiously, but it was convenient) and takes the name of a GPX file as its first argument.  It writes to stdout and is almost certainly not useful as anything more than an idea. </p>
<p>I initially planned to do this in JavaScript, but I realized it made a lot more sense to do it on the &#8220;server&#8221; side, before the data is sucked into the browser over the Internet&#8230;</p>
<p><b>Edit</b>: The idea for this kind of &#8220;compression&#8221; of GPS plots was taken from the virtual GPS units that <a href="http://www.ben.com/">Ben</a> implemented on <a href="http://www.waterpoint.org/">Waterpoint</a>, which record tracks for movement on the simulated ocean but use the same mechanism for reducing the number of track points stored. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.notes.xythian.net/2006/02/28/simplifying-gps-data-to-plot-polylines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
