Skip to main content

A Python wrapper for the geoviz JavaScript library

Project description

geovizpy

geovizpy is a Python wrapper for the geoviz JavaScript library, designed to bring the power of D3.js-based thematic mapping to Python. It allows you to create high-quality, interactive maps directly from Python scripts or Jupyter notebooks.

This library is a wrapper around the geoviz library. For detailed information on the underlying mapping logic, please refer to the original geoviz documentation.

Choropleth Map Example

Features

  • Simple, chainable API: Build complex maps by chaining intuitive methods.
  • Variety of Map Types: Create choropleth, proportional symbol, typology, and other thematic maps.
  • Interactive Controls: Add hover-to-expand controls for toggling layer visibility and exporting the map as SVG or PNG.
  • Customizable: Extensive options to customize colors, legends, strokes, and more.
  • Standalone HTML: Renders self-contained HTML files with no server required.
  • Image Export: Save maps directly to PNG or SVG from Python (requires optional dependencies).

Installation

Standard Installation

You can install the core library using pip:

pip install geovizpy

Or install directly from the source repository:

pip install git+https://codeberg.org/fbxyz/geovizpy.git

For Image Export

To save maps as PNG or SVG files directly from Python, you need to install the optional export dependencies:

  1. Install the extra dependencies:

    pip install "geovizpy[export]"
    
  2. Install Playwright's browser binaries:

    playwright install
    

    On Linux, you may also need to install host dependencies:

    sudo playwright install-deps
    

Quick Start

Here is a simple example of how to create a choropleth map:

from geovizpy import Geoviz
import json

# Load your GeoJSON data
# (Assuming 'world.json' is in a 'data' subdirectory)
with open("data/world.json") as f:
    world_data = json.load(f)

# Initialize the map
viz = Geoviz(projection="EqualEarth", width=800)

# Add layers
viz.outline()
viz.graticule()

# Add a choropleth layer
viz.choro(
    data=world_data,
    var="gdppc",
    colors="Blues",
    legend=True,
    leg_title="GDP per Capita"
)

# Add interactive controls
viz.add_layer_control(layers=["choropleth_gdp"])
viz.add_export_control()

# Save the map
viz.save("my_map.html")  # Renders an interactive HTML file
# viz.save("my_map.png")   # Renders a static PNG image (requires export dependencies)

Documentation

For more detailed information on all available methods and parameters, please see the full documentation.

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

geovizpy-0.1.12.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geovizpy-0.1.12-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file geovizpy-0.1.12.tar.gz.

File metadata

  • Download URL: geovizpy-0.1.12.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for geovizpy-0.1.12.tar.gz
Algorithm Hash digest
SHA256 c12aaa8f29278a52b567ecaff25783e17005ff74ded2f25b2cfd7b2860fbeab2
MD5 1f689f1b5e4b6a0b14e69a69c68aed10
BLAKE2b-256 392fec7f0c9a0808d1d15b4a6ada2257432cae768b9317e224f950ee86aa9789

See more details on using hashes here.

File details

Details for the file geovizpy-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: geovizpy-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for geovizpy-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 71aabcbcb84acc2b740595e29a2a04b4e65e818e795948bf90d67a8ac28c4e93
MD5 16ef5b32eb2b2d9bb8ee450d11bcfb7f
BLAKE2b-256 48b4456c7c66f55c0565901a7e281afec37f32e5c3dac678d5a79ebf36cc704e

See more details on using hashes here.

Supported by

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