Skip to main content

Widget for deck.gl maps

Project description

pydeck: Beautiful maps with Python

Get started and see interactive examples by clicking the badge below:

Binder

demo

Note that pydeck is under active development and not yet officially released. At the moment use of this library is experimental.

The pydeck library is a set of Python bindings for making spatial visualizations with deck.gl, optimized for a Jupyter Notebook environment.

Installation

pip install pydeck

If you are installing this for a Jupyter notebook server, you'll have to enable the widget extension. To do this, run:

jupyter nbextension install --sys-prefix --symlink --overwrite --py pydeck
jupyter nbextension enable --sys-prefix --py pydeck

Getting started

The following code renders a visualization similar to the one above in a Jupyter notebook:

import pydeck as pdk

# 2014 location of car accidents in the UK
UK_ACCIDENTS_DATA = 'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv'

# Define a layer to display on a map
layer = pdk.Layer(
    'HexagonLayer',
    UK_ACCIDENTS_DATA,
    get_position='[lng,lat]',
    auto_highlight=True,
    elevation_scale=50,
    pickable=True,
    elevation_range=[0, 3000],
    extruded=True,                 
    coverage=1)

# Set the viewport location
view_state = pdk.ViewState(
    longitude=-1.415,
    latitude=52.2323,
    zoom=6,
    min_zoom=5,
    max_zoom=15,
    pitch=40.5,
    bearing=-27.36)

# Render
r = pdk.Deck(layers=[layer], initial_view_state=view_state)
r.show()

If you're outside of a Jupyter notebook, you can alternately run:

r.to_html()

Debugging note

Because pydeck uses Python renders Javascript, some errors will appear only in the Javascript console. If you encounter an error, open the Javascript console in your browser. This will be updated in future versions of pydeck. If you encounter an issue, file it under the deck.gl issues page and include console output.

Installation from source

# Clone the deck.gl repo
git clone https://github.com/uber/deck.gl/

# Navigate to the pydeck module
cd deck.gl/bindings/python/pydeck

# Create a virtual environment
python3 -m venv env3
. env3/bin/activate

python3 setup.py install

Development

git clone https://github.com/uber/deck.gl/
cd deck.gl
# Build the entire deck.gl project
yarn bootstrap

# Optional but recommended: Run a hot reloading development server
cd modules/jupyter-widget
export PYDECK_DEV_SERVER=http://localhost:8080 && yarn watch

To specifiy a non-default URL for the webpack dev server, you can set a URL in the PYDECK_DEV_SERVER environment variable, e.g., export PYDECK_DEV_SERVER=http://localhost:8081.

Elsewhere, run:

export PYDECK_DEV_SERVER=http://localhost:8080
cd deck.gl/bindings/python/pydeck

# Create a virtual environment
python3 -m venv env3
. env3/bin/activate

pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -e .

Tests

Tests are handled by pytest. In this folder, you can type:

pytest

Tests expect the development build of pydeck, specified above. Click on the URLs in the test output to see visualizations generated by the tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydeck-0.1.dev2.tar.gz (110.5 kB view details)

Uploaded Source

Built Distribution

pydeck-0.1.dev2-py2.py3-none-any.whl (65.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pydeck-0.1.dev2.tar.gz.

File metadata

  • Download URL: pydeck-0.1.dev2.tar.gz
  • Upload date:
  • Size: 110.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.4

File hashes

Hashes for pydeck-0.1.dev2.tar.gz
Algorithm Hash digest
SHA256 854c00f8041e0a68331311c320d472ebd732b4cca3df908ca96991d3cb4f447e
MD5 ee6dca30e561a80c1039e30211a38ea6
BLAKE2b-256 9687a70b99c3c17e5537165b0939c7f08d23897d867308f02f035624f95e0e26

See more details on using hashes here.

File details

Details for the file pydeck-0.1.dev2-py2.py3-none-any.whl.

File metadata

  • Download URL: pydeck-0.1.dev2-py2.py3-none-any.whl
  • Upload date:
  • Size: 65.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.4

File hashes

Hashes for pydeck-0.1.dev2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fbc02f6e4e6b7ff609a628a03073a352f3d15b0dc324dc8c3289f5822d014081
MD5 ee70adc9544f29f9ce7a39d3a5b19c3a
BLAKE2b-256 f2871d6cc7aa1fa181afc2f59cb68c49ad498833efe2507dd9d1229aa602490d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page