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_:
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
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
| # | geometry | id | kind | name |
|---|---|---|---|---|
| 0 | 'eiffel' | 'landmark' | 'Eiffel Tower' | |
| 1 | 'champ' | 'park' | 'Champ-de-Mars' |
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
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
| CRS | EPSG:4326 |
|---|---|
| Name | WGS 84 |
| Authority | EPSG:4326 |
| Type | geographic_2d |
| Datum | World Geodetic System 1984 ensemble |
| Area of use | World. (-180.0000, -90.0000, 180.0000, 90.0000) |
| Axes | Lat (north, degree), Lon (east, degree) |
| Live geometries | 3 |
|---|---|
| CRS | EPSG: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.
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¶
- Arrow & storage — Arrow PyCapsules used to feed lonboard.
- Arrays & performance — vectorized array workflows.
- Grids & geocodes — H3, S2, Geohash, and XYZ tile cells.