Skip to main content

AnyWidget wrapper for globe.gl

Project description

pyglobegl

anywidget wrapper for globe.gl with integrations with popular Python spatial packages.

Installation

pip install pyglobegl

Or with uv:

uv add pyglobegl

Optional GeoPandas extra:

pip install pyglobegl[geopandas]
uv add pyglobegl[geopandas]

Quickstart

from pyglobegl import GlobeWidget, image_to_data_url
from PIL import Image

GlobeWidget()

Image Inputs

Globe image fields expect URLs, but you can pass a PIL image by converting it to a PNG data URL:

from pyglobegl import GlobeLayerConfig, image_to_data_url
from PIL import Image

image = Image.open("earth.png")
config = GlobeLayerConfig(globe_image_url=image_to_data_url(image))

Points Layer

from pyglobegl import (
    GlobeConfig,
    GlobeLayerConfig,
    GlobeWidget,
    PointDatum,
    PointsLayerConfig,
)

points = [
    PointDatum(lat=0, lng=0, size=0.25, color="#ff0000", label="Center"),
    PointDatum(lat=15, lng=-45, size=0.12, color="#00ff00", label="West"),
]

config = GlobeConfig(
    globe=GlobeLayerConfig(
        globe_image_url="https://cdn.jsdelivr.net/npm/three-globe/example/img/earth-day.jpg"
    ),
    points=PointsLayerConfig(
        points_data=points,
        point_altitude="size",
        point_color="color",
        point_label="label",
    ),
)

GlobeWidget(config=config)

GeoPandas Helper (Optional)

Convert a GeoDataFrame of point geometries into points data. The helper reprojects to EPSG:4326 before extracting lat/lng.

import geopandas as gpd

from pyglobegl import points_from_gdf

gdf = gpd.read_file("points.geojson")
points = points_from_gdf(gdf, include_columns=["name", "population"])

Goals

  • Provide a modern AnyWidget-based globe.gl wrapper for Jupyter, JupyterLab, Colab, VS Code, and marimo.
  • Ship a prebuilt JupyterLab extension via pip install (no separate lab build/extension install).
  • Keep the Python API friendly for spatial data workflows.

Roadmap

  • Near term

    • Expose globe.gl APIs in order (by section):
      • Initialisation
      • Container layout
      • Globe layer
      • Points layer
      • Arcs layer
      • Polygons layer
      • Paths layer
      • Heatmaps layer
      • Hex bin layer
      • Hexed polygons layer
      • Tiles layer
      • Particles layer
      • Rings layer
      • Labels layer
      • HTML elements layer
      • 3D objects layer
      • Custom layer
      • Render control
      • Utility options
    • Prioritize strongly typed, overload-heavy Python APIs with flexible input unions (e.g., accept Pillow images, NumPy arrays, or remote URLs anywhere globe.gl accepts textures/images).
    • Solidify a CRS-first API: detect CRS on inputs and auto-reproject to EPSG:4326 before emitting lat/lng data for globe.gl layers.
  • Mid term

    • GeoPandas adapter: map geometry types to globe.gl layers with sensible defaults and schema validation.
    • MovingPandas trajectories (static): accept trajectory/segment outputs and render via paths/arcs without time animation in v1.
    • Geometry-only inputs: accept bare geometry collections (Shapely or GeoJSON-like) as a convenience layer when CRS metadata is explicit.
  • Long term / research

    • GeoPolars exploration: track maturity and define an adapter plan once CRS metadata and extension types are stable upstream.
    • Raster feasibility: investigate mapping rasters to globe.gl via tiles, heatmaps, or sampled grids; document constraints and recommended workflows.

Contributing

Build Assets (Release Checklist)

  1. cd frontend && pnpm run build
  2. uv build

WSL2 Test Notes

  • WSL2 UI tests require WSLg with a working display socket (Wayland or X11) and WebGL available in the Playwright Chromium build.
  • If the UI tests are meant to enforce hardware acceleration, set PYGLOBEGL_REQUIRE_HW_ACCEL=1 before running pytest so software renderers skip early.
  • On WSL2, the UI test harness retries the browser launch with the D3D12-backed Mesa driver if the initial WebGL probe reports a software renderer. You can still set GALLIUM_DRIVER=d3d12 and MESA_LOADER_DRIVER_OVERRIDE=d3d12 manually, and optionally set PYGLOBEGL_WSL_GPU_ADAPTER=<GPU name> to map to MESA_D3D12_DEFAULT_ADAPTER_NAME when multiple adapters are present.

Windows Test Notes

  • The Playwright Chromium launch adds ANGLE GPU flags on Windows to prefer hardware acceleration (D3D11 via ANGLE). If the GPU path is unavailable, Chromium can still fall back to software rendering.

UI Test Artifacts

  • Canvas captures are saved under ui-artifacts as {test-name}-pass-<timestamp>.png or {test-name}-fail-<timestamp>.png.
  • Canvas comparisons use SSIM (structural similarity) with a fixed threshold (currently 0.86).

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

pyglobegl-0.3.1.tar.gz (771.0 kB view details)

Uploaded Source

Built Distribution

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

pyglobegl-0.3.1-py3-none-any.whl (772.9 kB view details)

Uploaded Python 3

File details

Details for the file pyglobegl-0.3.1.tar.gz.

File metadata

  • Download URL: pyglobegl-0.3.1.tar.gz
  • Upload date:
  • Size: 771.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyglobegl-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d46e7b6a2e7c080ec3cc04031d1794ffdc1745562fa5081bf535986b6481b670
MD5 1e05a41004c6b2f6c394fe2a8e943935
BLAKE2b-256 a6fad24c55822d84fecce78f713a0b0af72566e83cb9556f619b347fbcc59229

See more details on using hashes here.

File details

Details for the file pyglobegl-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pyglobegl-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 772.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyglobegl-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d0a023e91c6a03673f4b45bf22bb1cc3af18546d7004b1012d73ef7bcde8dd3
MD5 5f94f7674d6d616fa1aaca09cf26c64d
BLAKE2b-256 4a2f0f960a7b0fd5ff507e558a6770d8a8d402fd6ad17799fbeefa69d0478c3e

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