« Back to Projects

Traceroute Color Palette

| No Comments | Published on June 13, 2008
The content that follows was originally published on the Don Havey website at http://donhavey.com/projects/traceroute-color-palette/

Traceroute color palette between Portland and Greenland

I had this idea the other day: Make a screen that, when placed on the ground anywhere in the world, allows you to see the exact opposite side. Like your own portable hole through the center of the earth. I suppose it was inspired by this amazing installation.

Of course, I immediately dumbed down the idea a bit. I might pursue it eventually, once we have globally-available 1-foot-per-pixel satellite imagery, but for now, it’s not possible… without a lot of money (sponsorships appreciated!).

The variation became more of a programming challenge than an actual project. I decided to create an application that would choose a single color according to a user’s geographic coordinates, based on the satellite imagery available at that location. It essentially functions the same way as the original idea, except that it outputs only one pixel’s worth of color.

I made a quick prototype yesterday using only PHP. To test it, I hooked it up to a traceroute script and had it choose one color swatch per ‘hop’ on the traceroute, resulting in a color palette for the given route. Here are the steps:

  1. Using PHP’s PEAR Net library, execute a traceroute from the development server to any given domain or IP. Return a list of IP addresses of the hops along the way.
  2. Using the IP-to-geographic coordinates script that I made for the IP-mapping globe tutorial, translate each IP address to a longitude/latitude pair.
  3. Send each of those coordinates to a Google Maps page hosted on my server (developed with the Google Maps API), which centers a small map on that location and zooms in to the highest available satellite imagery resolution (that’s done via a custom Javascript error handler).
  4. My development server (running on Windows) takes a screenshot of that page using PHP’s COM commands. This part is very hacky, but trust me, using this workaround is much much easier than trying to grab the actual map images off of Google’s server… which also violates their Terms of Service, of course.
  5. PHP’s GD2 library analyzes the part of the screenshot that contains the map and averages the colors for that geographic location.
  6. Each color swatch is saved as a new png and output to the browser.

Unfortunately, since it’s set up to run only on a Window’s server (the screenshot command is not *nix compatible), I can’t show a working version. If there’s any interest in the code, I can post it, but again, until I find a more stable way to do this, it remains a development-server-only project.

The image above is the route between me (Portland, ME, USA) and the website nanoq.gl which is in Greenland. The traceroute is as follows:

Saco, ME, US -> Portland, ME, US -> Fulton, NY, US (x2) -> New York, NY, US -> Minneapolis, MN, US -> New York, NY, US (x2) -> Tim, Denmark -> Copenhagen, Denmark -> Nuuk, Greenland (x2)

It takes about 6 minutes per color palette, because the traceroute takes a while, and of course, the screen capture routine requires a delay between each page request to ensure that the page loads properly (Google Maps applications are loaded via the onload() function).

Kind of boring, but maybe some will find it interesting. I haven’t seen too many projects that analyze satellite imagery. Maybe that’s because no one finds it interesting… but I’d guess that it’s more related to the fact that it’s so damn hard to interface with map servers, and most interesting applications would probably defy somebody’s Terms of Service and get shut down anyway.