GithubHelp home page GithubHelp logo

mantyr / density Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fogleman/density

0.0 3.0 0.0 29 KB

Render millions of points on a map.

Home Page: https://www.michaelfogleman.com/static/density/

Go 90.14% JavaScript 4.00% HTML 5.19% CSS 0.67%

density's Introduction

High-density Point Maps

Render millions of points on a map.

Map

Demo Site

This demo shows 77 million taxi pickups in NYC - from January to June 2015.

https://www.michaelfogleman.com/static/density/

Dependencies

  • Go
  • Cassandra

Download

go get github.com/fogleman/density

Loading Data

Cassandra is used to store large amounts of data. Data is clustered by (zoom, x, y) so that all of the points inside of a tile can quickly be fetched for rendering, even faster than PostGIS with an index.

First, create a new keyspace and table to house the data.

create keyspace density
    with replication = {
        'class': 'SimpleStrategy',
        'replication_factor': 1
    }
    and durable_writes = false;

create table points (
    zoom int,
    x int,
    y int,
    lat double,
    lng double,
    primary key ((zoom, x, y), lat, lng)
);

Next, load points into the database from a CSV file using the loader script.

go run loader/main.go < input.csv

Several command line options are available:

Flag Default Description
-keyspace density Cassandra keyspace to load into
-table points Cassandra table to load into
-lat 0 CSV column index of latitude values
-lng 1 CSV column index of longitude values
-zoom 18 Zoom level to use for binning points

Just run the loader whenever you need to insert more data.

Serving Tiles

Once the data is loaded into Cassandra, the tile server can be run for rendering tiles on the fly.

go run server/main.go
Flag Default Description
-keyspace density Cassandra keyspace to load from
-table points Cassandra table to load from
-zoom 18 Zoom level that was used for binning points
-port 5000 Tile server port number
-cache cache Directory for caching tile images

Serving Maps

A simple Leaflet map is provided to display a base map with the point tiles on top in a separate layer.

cd web
python -m SimpleHTTPServer

Then visit http://localhost:8000/ in your browser!

TODO

  • tile rendering options
  • multiple layers

density's People

Contributors

fogleman avatar

Watchers

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