Giter Site home page Giter Site logo

d3-grid-map's Introduction

d3-grid-map

D3 gridded data set mapper

See demo

This package will draw a geographic map on an html5 canvas using D3 in the container of your choosing. Gridded and vector data layers can be added to the returned map object using its addLayer method.

For instance, land outlines can be drawn from the included countries.topojson data.

Usage

Pass a DOM container selector string and optional arguments to d3.geo.GridMap to initialize a GridMap object, then add data sets via its addLayer() method.

The data can be in several forms, all handled by addLayer:

var map = new d3.geo.GridMap('#container');

// an ArrayBuffer buff containing data in
// packed binary format

// The packed binary format is expected to be
// a sequence of Uint32 elements in which the most
// significant byte is the cell value and the
// lowest 3 bytes represent the cell ID.
var layer1 = map.addLayer(buffer, {gridSize: [10, 10]});

// a UInt8ClampedArray containing data in
// RGBA format

// The format is expected to be
// a sequence of Uint8 elements representing RGBA
// values for each cell from cell ID 1 to the final cell ID,
// in column first order.
var layer2 = map.addLayer(data,  {gridSize: [10, 10]});

// a geojson or topojson object:
var layer3 = map.addLayer(geojson);

Options

map.addLayer(data, options)

options:

  • zIndex - higher numbers will be stacked on top of lower numbers

Example

d3.json('data/countries.topojson', function(error, countries) {

  var gridSize = [720, 360];

  var options = {
    hud: {
      fontSize: 20,
      fontColor: 'white',
      verticalOffset: 5
    },
    projection: d3.geo.aitoff(),
    onCellHover: function(feature) { console.debug('hovering over ', feature);}
  };

  var map = d3.geo.GridMap('#container', options);

  map.addLayer(countries, {zIndex: 1});

  map.addLayer(data, {gridSize: gridSize, zIndex: 2});
});

Development

install dependencies with

npm install
bower install

Then build with

make

To start up an autoreloading development server on the demo index.html:

make develop

d3-grid-map's People

Contributors

jsheedy avatar motionsmith avatar

Watchers

James Cloos avatar  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.