Skip to content

Notebooks & visualization

Every core gometry type renders a rich, theme-adaptive HTML or SVG preview in Jupyter with no optional dependencies. Install gometry[viz] to add interactive lonboard maps.

Built-in notebook previews

In Jupyter and other IPython frontends, gometry objects render automatically via _repr_html_ and _repr_svg_. Styling adapts to light and dark notebook themes, and large inputs are bounded so previews stay responsive:

Type Notebook preview
Geometry Inline SVG preview with geometry type, CRS, and bounds summary (complex shapes are downsampled for display)
GeometryArray Interactive lonboard map when gometry[viz] is installed and the CRS can be displayed in WGS 84; otherwise a capped SVG thumbnail grid
CRS Structured authority, axis, and unit summary card
Feature, Features Geometry SVG preview alongside feature ID and properties table
H3Cell, S2Cell, GeohashCell, Tile, CellArray Cell metadata and inline polygon SVG preview (capped grid for arrays)
SpatialIndex Index size, CRS, and spatial extent card
ListArray Row count, total elements, and sample row lengths

Representative notebook outputs rendered directly from gometry's _repr_html_:

partial: notebook cell
import gometry as gm

wgs84 = gm.Space(crs=4326)
arr = gm.GeometryArray([
    gm.box(0, 0, 2, 2, space=wgs84),
    gm.Point(1, 1, space=wgs84).buffer(10_000),
    gm.LineString([(0, 0), (1, 2), (2, 0)], space=wgs84),
    gm.Polygon([(0, 0), (2, 0), (1, 2)], space=wgs84),
], space=wgs84)
arr
4 geometries
partial: notebook cell
import gometry as gm

features = gm.from_geojson('''
{"type":"FeatureCollection","features":[
  {"type":"Feature","id":"eiffel","properties":{"name":"Eiffel Tower","kind":"landmark"},
   "geometry":{"type":"Point","coordinates":[2.2945,48.8584]}},
  {"type":"Feature","id":"champ","properties":{"name":"Champ-de-Mars","kind":"park"},
   "geometry":{"type":"Polygon","coordinates":[[[2.290,48.855],[2.296,48.855],[2.296,48.858],[2.290,48.858],[2.290,48.855]]]}}
]}
''', crs=4326)
features
2 features · EPSG:4326
#geometryidkindname
0
'eiffel''landmark''Eiffel Tower'
1
'champ''park''Champ-de-Mars'
partial: notebook cell
import gometry as gm

station = gm.Point(2.2945, 48.8584, space=gm.Space(crs=4326))
cells = gm.h3_cover(station.buffer(500), resolution=10)
cells
<CellArray[H3Cell] len=76> (showing first 12)
partial: notebook cell
import gometry as gm

crs = gm.CRS(4326)
idx = gm.SpatialIndex(gm.points([2.29, 2.31, 2.35], [48.85, 48.86, 48.87], space=gm.Space(crs=crs)))
crs, idx
CRSEPSG:4326
NameWGS 84
AuthorityEPSG:4326
Typegeographic_2d
DatumWorld Geodetic System 1984 ensemble
Area of useWorld. (-180.0000, -90.0000, 180.0000, 90.0000)
AxesLat (north, degree), Lon (east, degree)
<SpatialIndex len=3 crs=EPSG:4326>
Live geometries3
CRSEPSG:4326
Bounds(2.2900, 48.8500, 2.3500, 48.8700)

To force the lightweight SVG grid for a GeometryArray even when lonboard is installed, call _repr_html_svg().

Interactive maps with gm.explore()

Install gometry[viz] to enable interactive maps:

uv add "gometry[viz]"
pip install "gometry[viz]"

gm.explore accepts a Geometry, GeometryArray, Features, scalar Cell, or CellArray and hands it to lonboard through the Arrow PyCapsule interface. Inputs need a CRS and finite bounds; cells and cell arrays convert to their WGS 84 polygons automatically.

partial: requires gometry[viz]
import gometry as gm

station = gm.Point(2.2945, 48.8584, space=gm.Space(crs=4326))
cells = gm.h3_cover(station.buffer(500), resolution=10)

gm.explore(
    cells,
    polygon_kwargs={"get_fill_color": [15, 118, 110, 120]},
)

By default, explore() renders points, lines, and polygons distinctly with hover inspection. Pass lonboard's scatterplot_kwargs, path_kwargs, polygon_kwargs, or map_kwargs to customize styling.

WGS 84 display reprojection and automatic fallback

lonboard expects WGS 84 longitude/latitude display coordinates. gm.explore() and GeometryArray._repr_html_ reproject projected and non-WGS 84 geographic frames toward EPSG:4326 for display. If an array has no CRS, cannot be reprojected, or exceeds the automatic preview size cap, GeometryArray._repr_html_ falls back to the SVG grid automatically.

See also