Python heatmap library
Switch branches/tags
Nothing to show
Clone or download
chucknthem Merge pull request #1 from dustin/master
Cleaned up a temporary file.
Latest commit 23d8225 Sep 23, 2011
Failed to load latest commit information.

Heatmap 1.1

orig author: jjguy modified by: chucknthem This is fork of heatmap by jjguy. It's about 30 times faster than the original version 1.0.


heatmap is a python library for creating heatmaps.

Works with gps coordinates and generates KML files for overlaying heatmaps on Google Earth.

Full documentation at

See Also:


Either clone this git repo or download the source. Then install it as a normal python package:

python install

Modifications to the original:

  1. New and faster heatmap generating algorithm.
  2. Fixed an issue with points at the border of the heatmap being clipped.
  3. Allows generating a time sequenced kml file for visualising heatmaps over time.

Generating a time sequenced heat map for Google Earth.

hm = heatmap.Heatmap() 
  size=(2048, 2048),

Most parameters are the same as the heatmap() function described below. The only difference is the 'pointset' parameter which is defined as follows:

pointset = [(begin, end, [lat, lng]), (begin, end, [lat, lng]), ...]

where begin and end are dates in the format yyyy-mm-dd

This will generate a single .kml file and n = len(pointset) .png files.

Original documentation from

heatmap() has only two required parameters:

A list of two-element tuples
The filename to save the resulting image
There are several optional parameters, with reasonable defaults:
   |  heatmap(self, points, fout, dotsize=150, opacity=128, size=(1024, 1024), scheme='classic')
   |      points  -> an iteratable list of tuples, where the contents are the
   |                 x,y coordinates to plot. e.g., [(1, 1), (2, 2), (3, 3)]
   |      fout    -> output file for the PNG
   |      dotsize -> the size of a single coordinate in the output image in
   |                 pixels, default is 150px.  Tweak this parameter to adjust
   |                 the resulting heatmap.
   |      opacity -> the strength of a single coordiniate in the output image.
   |                 Tweak this parameter to adjust the resulting heatmap.
   |      size    -> tuple with the width, height in pixels of the output PNG
   |      scheme  -> Name of color scheme to use to color the output image.
   |                 Use schemes() to get list.  (images are in source distro)

Examples from jjguy's website:

Make a random heatmap:

import heatmap
import random

if __name__ == "__main__":    
    pts = []
    for x in range(400):
        pts.append((random.random(), random.random() ))

    print "Processing %d points..." % len(pts)

    hm = heatmap.Heatmap()
    hm.heatmap(pts, "classic.png")

Creating a heatmap for google earth:

import heatmap
import random

hm = heatmap.Heatmap()
pts = [(random.uniform(-77.012, -77.050), random.uniform(38.888, 38.910)) for x in range(100)]
hm.heatmap(pts, "classic.png")

The original readme is below:

heatmap 1.0

Build heatmaps in python. Requires the Python Imaging Library.

Minimal example in Full readme at