GithubHelp home page GithubHelp logo

dtmheatmap's Introduction

DTMHeatmap

A heatmap for iOS, implemented as an MKOverlay to provide seamless integration with MapKit.

This project is based on https://github.com/ryanolsonk/HeatMapDemo. It has been updated to improve performance and add a "diff" mode. https://github.com/gpolak/LFHeatMap was also referenced.

Modes

Standard

This mode is a standard heatmap and should produce the same results as the original HeatMapDemo project, but more quickly.

Diff

This mode compares two sets of data to visualize which areas have "heated up" and which have "cooled down". Increased activity is shown with warm colors, decreased activity is shown with cool colors.

Installation

The easiest way to get DTMHeatmap is via Cocoapods

pod 'DTMHeatmap'

Usage

Using DTMHeatmap is relatively straightforward. After installing using the instructions above: 0. Register as a delegate of your map view

  1. Create an instance of DTMHeatmap
  2. Provide data in the form of a dictionary mapping MKMapPoint (wrapped in NSValue using [NSValue value:&point withObjCType:@encode(MKMapPoint)]) to weights
  3. Add the heatmap as an overlay to your map view.

In the simplest form, the code looks something like this:

- (void)viewDidLoad
{
    self.mapView.delegate = self;

    // Create DTMHeatmap
    self.heatmap = [DTMHeatmap new];
    [self.heatmap setData:myData];
    [self.mapView addOverlay:self.heatmap];

    // or...
    // Create DTMDiffHeatmap
    self.diffHeatmap = [DTMDiffHeatmap new];
    [self.diffHeatmap setBeforeData:beforeData
                          afterData:afterData];
    [self.mapView addOverlay:self.diffHeatmap];
}

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
            rendererForOverlay:(id<MKOverlay>)overlay
{
    return [[DTMHeatmapRenderer alloc] initWithOverlay:overlay];
}

As you can see, the only difference between the stanard heatmap API and that of the diff heatmap is that the diff heatmap requires two sets of data โ€“ before and after.

Example Project

A sample project (DTMHeatmapExample) has been provided to demonstrate basic usage. There are currently four visualization options:

  • Standard: shows US locations of McDonald's as a regular heatmap
  • Week 1: shows Sacramento crime data for the first week of January 2006 as a regular heatmap
  • Week 3: shows Sacramento crime data for the third week of January 2006 as a regular heatmap
  • Diff: compares the data from Week 3 to Week 1 as a diff heatmap. As one might expect, the diff is fairly random. If you can recommend a better dataset, please let me know :)

Data Sources

McDonald's Locations

[Sacremento Crime Data](http://samplecsvs.s3.amazonaws.com/SacramentocrimeJanuary2006.csv at http://support.spatialkey.com/spatialkey-sample-csv-data/)

dtmheatmap's People

Contributors

rameezhandel avatar

Watchers

Rameez Ibrahim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.