This is a cross post from 22Michaels, a blog about the adventures of Michael Fox, Jodie Fox and Mike Knapp from Shoes of Prey.
As an early employee of the unique design your own shoe company Shoes of Prey, I’m intrigued by how quickly the company is growing. It seems like every time I walk into the office there is a new employee in Sydney or one of it’s partner offices around the world. As the business spreads into new markets across the globe, we start to ask questions like “how quickly are we growing in Japan?”, “how successful was our valentine’s day campaign?“, “how can we replicate our Australian success in Russia?”. We can take information like where and when we’re making a sale and apply basic statistics and number crunching-fu to try and answer some of those questions, but that’s no fun. What if we could see our growth with our eyes?
Google earth is an excellent tool for visualizing geo-location data, and that’s exactly what we chose to use. In a few hours, I was able to create a visualisation of shoe sales around the world over time. Here is a video of Australian sales:
Seeing the growth of Shoes of Prey over time is exciting, and it only takes the right tools and bit of programming background to put something like this together. This post gets technical from here, so skip to the end of that’s not your cup of tea.
Displaying time sequence animations in Google Earth is easy, it’s a matter of getting your data in the right format. It uses a format called KML, for which you can find documentation here. I’ll summarize what it took to put the animation together.
You can place a “placemark” on the map with the following tag:
<?xml version=”1.0″ encoding=”UTF-8″?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>
</kml>
Furthermore, you can add a custom icon as well as a “TimeSpan” to specify when to display that “placemark”. This is what we use to display those red shoe icons on the map.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="iconStyle">
<IconStyle>
<scale>1.0</scale>
<Icon><href>shoe.gif</href></Icon>
</IconStyle>
</Style>
<Placemark>
<TimeSpan>
<begin>2009-10-09</begin>
<end>2009-10-16</end>
</TimeSpan>
<styleUrl>#iconStyle</styleUrl>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
The “kml” above will display a single shoe icon at GPS coordinates (-122.0822035425683, 37.42228990140251), you can add more points by adding more <Placemark> sections.
Creating and animating heat maps is more difficult and will require some programming. Python is a major programming language we use at Shoes of Prey and luckily I found a Python library that not only generates heat maps, but also generates kml code to overlay the heat map on Google Earth. The heat map library by itself had a few limitations for what we wanted to do; mainly, it was too slow and it was limited to only generating a single static heat map and kml file. However, the great thing about open source software with modification friendly licenses is that you can modify it if it doesn’t do exactly what you want it to do. I had to modify the library to make it faster and generate a time sequence of heat maps like the one you see in the video. You can find the source code of the modified version here. All you have to do is give it the data in the right format, the library does the hard work for you.
import heatmap
# Code to format your data goes here #
hm = heatmap.Heatmap()
hm.animated_heatmapKML(pointsets, outfile_name)
The first argument to the animated_heatmapKML functino takes an array of 3-tupples in the format like below:
pointsets = [(start_date, end_date, [lat, lng]), (start_date, end_date, [lat, lng]), …]
The second argument is the name of the output file, e.g. “heatmap.kml”. There are other optional parameters, see the documentation for more details. That should generate a “heatmap.kml” file as well as associated heatmap images heatmap.kml1.png, heatmap.kml2.png, … to go with it. Open the file in google earth and slide the timeline to see the heatmap change over time.
What do you do with your business’ data and how do you use it to improve your business?

