Applying weighting to heatmaps

Heatmap with weighting applied

Following up on the playing around I was having with heatmaps the other day, I made a few updates to the script to allow for each point to have an associated ‘intensity’. When the points are plotted, the intensities are normalised and each point plotted with a relative intensity (as shown in the image on the right).
Few other little changes I made:

  • allow the area covered by the size of the final image to be specified, rather than using the max & min x/y coordinates from the input points
  • change how the the dots are built – in theory should be a little quicker – but I’ve not tested with large enough dataset to know if it makes a big difference
  • in my demo script I’ve shown how you can convert the latitude to its Mercartor projection coordinate

For those interested in the changes I made to the script you can download the diff and an example script. Any feedback, comments welcome 🙂


  1. R0ot says:

    Hey, I’m trying to follow the README file on execution. Is there a example I can follow? I’ve downloaded the script and am just unsure on what to do exactly next. Thanks and this is a pretty cool script for heatmap. Cheers!

  2. Alex Little says:

    @R0ot – apologies for long delay getting back to you. It’s been a while since I did anything with these heatmaps – so had to refresh myself a little!

    Essentially what you’ll need to do is…

    1. Download the original file and apply the diff to make the necessary updates
    2. Create a db and table – the script uses MySQL, but sure can be adapted easily enough for other db types. The table just needs 3 columns – ‘lat’, ‘lng’ and ‘intensity’ – with a few rows of data
    3. Update the file to put in your db name, user & password – and also int eh query update to show the name of the table you created
    4. Run the file

    Hope that helps

Leave a Reply