Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

ajduberstein/slayer

Repository files navigation

slayer.py

build

Short for "Spatial Layers," Slayer is a Python wrapper around deck.gl.

Features

  • Scale. Built on deck.gl, Slayer plots hundreds of thousands of points.
  • Focus on Data Science, Analytics, and GIS. API treats Pandas as a first class citizen.
  • Time. Built for plotting data over time.

For example, 1.6M LIDAR points visualized here:

slayer.py

Example usage

Plotting all registered businesses in San Francisco by neighborhood:

import slayer as sly
import pandas as pd

# A data frame of all the businesses registered in SF in the last 50+ years
DATA_URL = 'https://raw.githubusercontent.com/ajduberstein/sf_growth/master/public/data/business.csv'
businesses = pd.read_csv(DATA_URL)

# Automatically fit to the center 95% of your data
auto_view = sly.Viewport.autocompute(businesses[['lng', 'lat']], view_proportion=0.95)

# Create a random set of 100 colors, on the variable `neighborhood`
color_scale = sly.ColorScale(
   num_classes=100,
   palette='random',
   variable_name='neighborhood',
   scale_type='categorical_random')

# Create a geospatial scatterplot
s = sly.Slayer(auto_view, drag_boxes=True)
L = sly.Scatterplot(
   businesses,
   position=['lng', 'lat'],
   radius=50,
   color=color_scale)

# Write it out to disk and visualize it
# If in a Jupyter notebook, a pane will open
(s + L).to_html('demo.html', interactive=True)

Installation

Get a Mapbox API key and set it as an environment variable (or list it in your script as above).

This package isn't on Pip yet.

In the shell, type:

>>> git clone https://github.com/ajduberstein/slayer
>>> cd slayer
>>> python setup.py install

About

Visualize objects in space and time in Python

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages