digitalearth as a pyramids plot backend#
pyramids renders through cleopatra (matplotlib) by default. Ask any pyramids object for another backend and it looks for a registered renderer:
from pyramids.dataset import Dataset
ds = Dataset.read_file("examples/data/acc4000.tif")
ds.plot() # matplotlib, through cleopatra — pyramids' own path
ds.plot(backend="static") # a digitalearth Map (matplotlib, this package's own)
ds.plot(backend="interactive") # a digitalearth InteractiveMap
ds.plot(backend="3d") # a digitalearth Scene3D
ds.plot(backend="web") # a digitalearth WebMap
digitalearth registers itself for those four names in the pyramids.plot_backends entry-point
group, so pyramids discovers it rather than importing it by name. The dependency stays one-way —
digitalearth depends on pyramids-core; pyramids never names digitalearth in its own code.
The matplotlib tier is named static, after the subpackage that implements it. That is its
canonical name throughout this package — the key BACKEND_CAPABILITIES is built on, the column the
support matrix shows, and what quickmap(backend=…) defaults to; matplotlib is accepted as an
alias of it. It also has to be the registered name, because matplotlib cannot be: Dataset.plot branches on
if backend != "matplotlib" and takes its own cleopatra path before it consults the registry, so
an entry point under that name would never be resolved. ds.plot() and ds.plot(backend="matplotlib")
therefore keep returning a cleopatra glyph, unchanged, and backend="static" is how you ask for
this package's Map.
digitalearth.quickmap accepts both spellings — digitalearth.api.BACKEND_ALIASES is the table, and
--backend static works on the CLI too — so code moving between the facade and the package directly
does not have to rename the backend as it goes.
# digitalearth's pyproject.toml
[project.entry-points."pyramids.plot_backends"]
static = "digitalearth.pyramids_backend:static"
interactive = "digitalearth.pyramids_backend:interactive"
"3d" = "digitalearth.pyramids_backend:three_d"
web = "digitalearth.pyramids_backend:web"
You do not install anything extra for this
A registered entry point simply wins over the fallback pyramids keeps for a plain digitalearth install. The difference is what happens to the arguments — see below.
Why an adapter, and not just quickmap#
pyramids forwards the data-selection arguments of the call it was given, in its own vocabulary. Three of those names mean something different here, so they are translated on the way in. Everything else passes through untouched.
| pyramids forwards | digitalearth takes | Why |
|---|---|---|
band=0 (0-based) |
band=1 (1-based) |
0-based upstream, 1-based here; unshifted it was refused. |
variable_name= |
variable= |
The MeshDataset facade's spelling.Live on static — see below. |
interval=200 (ms/frame) |
fps=5.0 |
The facades describe an interval; the tier verbs take a rate. |
cmap, variable, a bool colorbar and band (once shifted) are forwarded to the builder as they
arrive. Three others are not simply passed along, because the tiers differ:
titleis applied through the scene, not the builder. The web and 3-D raster builders refuse it (RasterMixin.field() got an unexpected keyword argument 'title', and on 3-D PyVista's own"title" is an invalid keyword argument), so it is set withset_titleafter the scene is built. The HoloViz tier has noset_titleand does accepttitle, so there it stays with the builder.basemapis a verb on the scene in every tier that has one, never a constructor argument.kindreaches the builder, but only the HoloViz tier has alternative raster renderers. On web and 3-D a non-defaultkindis refused by that tier:kind= is not supported by backend='web'.
A column is forwarded, and is accepted only where that tier's render takes one — on a still raster
plot it is refused by the tier ('column' is not an option Image takes on the bokeh backend).
What is refused, and why it is refused here#
pyramids drops defaulted arguments before forwarding, so anything that arrives was set deliberately. An argument this seam cannot honour is refused by name, in terms of the call you made. Left to the tier it is still refused — but for the builder it happened to reach, and on the 3-D tier in PyVista's terms rather than digitalearth's:
ds.plot(backend="3d", title="DEM")
TypeError: "title" is an invalid keyword argument for `_common_arg_parser`
| Refused | Do this instead |
|---|---|
exclude_value |
No entry point here takes a nodata value; mask the raster in pyramids before plotting. |
rgb_options |
Call Map.rgb_composite throughquickmap or Map; this seam nevercalls it. |
selectors, axes |
Choose a NetCDF slice with variable= and band=. |
bands, animation_axis_values, intervalon a still plot |
Call animate(backend=…) instead. |
The matplotlib-only styling (the typed color / contour / cells / data_style / classify
groups, the points overlay and a ColorBar instance) never reaches here at all — pyramids
rejects those before dispatch.
Moving from ds.plot() to ds.plot(backend="static")
The two are different renderers, so the table above applies to static as well — even though it
is the same engine as pyramids' default. exclude_value and rgb_options are accepted by
ds.plot() and refused here:
ds.plot(backend="static", band=0, exclude_value=0)
ValueError: plot(…) cannot serve 1 argument(s) on backend='static': exclude_value= — …
This is the first thing a caller switching over hits. ds.plot() keeps working exactly as it
did — nothing about the default path changed.
Animation#
Dataset.animate(backend=…) and friends forward animate=True. Two of the four tiers can serve it:
from pyramids.dataset.collection import DatasetCollection
stack = DatasetCollection.from_files(["examples/data/acc4000.tif"] * 3)
stack.animate(backend="interactive", interval=120) # a Panel player
stack.animate(backend="interactive", interval=120, path="flood.gif") # written to a file
stack.animate(backend="web", interval=120, path="flood.gif") # written to a file
Leave interval out and the speed is digitalearth's, not pyramids'
With no interval forwarded, the tier uses digitalearth's shared DEFAULT_FPS of 3.0, which
is 333 ms a frame, where a plain stack.animate() on matplotlib runs at pyramids' own
default of 200 ms. Pass an interval when the speed matters.
Whether a default interval=200 reaches the backend at all depends on the facade:
Dataset.animate declares the parameter and drops it when it is unchanged, so the backend
cannot tell "asked for 200 ms" from "said nothing"; DatasetCollection.animate forwards
**kwargs verbatim, so there a 200 you pass does arrive (round-2 L8).
The web animation needs a headless browser
digitalearth[web] does not install one, so the web example above raises until you add it:
ImportError: GIF export needs a headless browser … Install Playwright
(pip install playwright && python -m playwright install chromium) or Selenium + a driver.
The interactive tier needs nothing extra for its player (round-2 L1).
- interactive builds a time cube and returns a Panel player, or writes a GIF/MP4 when you pass a
path. - web animates only to a file, so
path=is required; without one the call is refused by name. - static is refused by name.
Map.animateworks and takes a stack, and a forwardedpath=reaches this seam just as it does for the web tier — butMap.animatehands back a lazy matplotlibFuncAnimationand does not write it, so saving one would be this seam's own step and it does not take it yet. Build theMapwith digitalearth and callMap.animateon your stack. A still plot of aDatasetCollectionlands on this refusal too, becauseDatasetCollection.plotforwardsanimate=Trueeither way. - 3-D is refused by name. Its
Scene3D.recordneeds a caller-suppliedupdatecallable andScene3D.orbitsweeps the camera over a static scene, so neither can be driven from a plot call's keywords. Build the scene with digitalearth and call one of them directly.
What you can reach through plot(backend=…), and what needs an import#
The call hands back the tier's own object, exactly as ds.plot() hands back a cleopatra glyph —
so every method on that object is in reach by chaining, and so is every attribute it exposes:
A tier scene's own settings go in scene_kw, which keeps them out of the render's keywords:
ds.plot(backend="web", band=0, scene_kw={"center": (31.0, 30.0), "zoom": 6, "style": "light"})
ds.plot(backend="interactive", band=0, scene_kw={"width": 1100, "height": 700})
The matplotlib tier takes it too, under its registered name:
backend="matplotlib" is the one spelling that does not reach this package: pyramids
short-circuits that name to cleopatra before consulting the registry, so ds.plot(scene_kw=…) is
refused by cleopatra in its own words. Ask for backend="static" instead, or call
digitalearth.quickmap directly.
They need their own mapping because a name alone cannot say which object it is for. height is the
web map's pixel height, and WebMap.extrusion's extrusion height, and the Datashader canvas
height the HoloViz tier takes out of a builder's **opts. So both can be asked for at once, and
each reaches its own object:
Outside scene_kw, height stays the render's, and the builder answers for it. On a polygon layer
that answer is a refusal, because quickmap draws polygons through polygons() — height belongs to
WebMap.extrusion, which it does not call:
polygons.plot(backend="web", height=50_000)
TypeError: VectorMixin.polygons() got an unexpected keyword argument 'height'
That refusal is the point: the same name reaches a different object on each side of the namespace, and neither side quietly swallows the other's keyword. An earlier attempt at this feature inferred the destination from signatures instead, and turned exactly that refusal into a 50,000-pixel map.
A key the scene does not take is refused by the scene, naming it:
de.quickmap(ds, band=1, scene_kw={"not_a_scene_option": 1})
TypeError: GeoLayerBase.__init__() got an unexpected keyword argument 'not_a_scene_option'
scene_kw hands you the scene's own behaviour
Its contents go to the tier's constructor unscreened, so a value that class does not validate
is not validated here either — scene_kw={"style": 3} builds a WebMap with style == 3 and
fails later, as WebMap(style=3) does. That is deliberate: screening the values would mean this
layer keeping a second opinion about every tier's constructor. These names are also outside
BACKEND_CAPABILITIES and the support matrix, which answer which capability a tier declares —
a scene setting has none behind it.
Two things need import digitalearth, and no keyword can change that:
- Composition across scenes. One call returns one scene, so
grid,facetandquickpanels— which build their own panels — cannot come back from it. - Everything that is not a scene: the charts and statistical series (
bar,boxplot,envelope,stripes,quantile_band),TexturedGlobe,TimeSeries,Climatology, the batch renderer and HTML gallery (Batch,gallery), andto_backend.
A mesh is drawn on static, and refused on the other three#
Only the matplotlib tier has a triangular render, which digitalearth.api.MESH_BACKENDS states. Since
static is that tier, a MeshDataset draws there — shading the mesh's own faces, not a
re-triangulation — and that is what the variable_name → variable translation above is for:
On the other three it is refused before any keyword is read:
MeshDataset.plot(backend="web")
TypeError: backend='web' has no unstructured-mesh render; draw a MeshDataset on the
matplotlib tier, which shades each of its faces (tripcolor): quickmap(data,
backend='matplotlib') here, or plot(backend='static') through pyramids, whose own
'matplotlib' is cleopatra's path
Checking what is registered#
from pyramids.base._plot_backends import plot_backends, resolve_plot_backend
sorted(plot_backends()) # ['3d', 'interactive', 'static', 'web']
resolve_plot_backend("interactive") # the callable itself, loaded from the entry point
A registered entry point resolves to the callable — not to its module:attr string, and not to
the functools.partial over quickmap that the fallback would hand back. That difference is how you
tell the two apart.
The seam arrived in pyramids-core 0.73.0
The pyramids.plot_backends group is resolved by pyramids-core's plot-backend seam, which first
shipped in 0.73.0 — 0.72.0 was published after the seam merged but cut from a commit
without it, so it carries neither pyramids.base._plot_backends nor the conformance kit, and
its Dataset.plot has no backend= keyword. So 0.73.0 is the oldest release this seam resolves
on; the declared floor is higher (>=0.75.0) for an unrelated reason — this package uses the
names 0.75.0 canonicalised (metadata, band_metadata, nearest_cell, total_bounds,
MeshDataset), which do not exist on 0.73.0.
Verified against 0.75.0:
digitalearth.pyramids_backend
#
Serve pyramids' plot(backend=…) seam from digitalearth's four rendering tiers.
pyramids-core resolves a non-matplotlib backend= through the pyramids.plot_backends
entry-point group: Dataset.plot(backend="3d"), NetCDF.plot(backend="interactive") and the
rest hand the object to whichever callable is registered under that name. This module is the
registered end of that seam — one callable per tier, each matching the contract shape
fn(obj, *, backend, **kwargs).
Registering it is not merely cosmetic. Without an entry point pyramids falls back to importing
digitalearth by name and calling quickmap directly, which forwards its own vocabulary
verbatim. Each tier then answers in its own terms, naming its internal builder rather than the call
the caller made — and on one tier the complaint is not even digitalearth's:
ds.plot(backend="web", title="DEM")
TypeError: RasterMixin.field() got an unexpected keyword argument 'title'. Did you mean 'tiles'?
ds.plot(backend="interactive", rgb_options={})
ValueError: 'rgb_options' is not an option Image takes on the bokeh backend; did you mean
['xrotation', 'yrotation']?
ds.plot(backend="3d", title="DEM")
TypeError: "title" is an invalid keyword argument for `_common_arg_parser`
The last is PyVista's own argument parser, surfacing to someone who wrote ds.plot(backend="3d",
title=…). So the adapter's job is to translate between the two vocabularies, to apply a frame
keyword through the route that tier actually has, and to refuse the keywords it knows about by
name, before a scene is half-built — not to convert silence into a message, since the tiers were
never silent.
That last qualifier is the honest scope. This module checks the keywords the facades are documented
to forward: the ones no tier can serve (:data:_UNSERVED), the animation-only ones, the frame ones,
and — on the animate path, where it knows the builder — every remaining keyword against that
builder's signature. A keyword outside that set still reaches the tier on a still plot and is
answered there, in the terms quoted above, because quickmap takes **kwargs and there is no
signature to check it against (round-2 M2).
Three translations are genuinely necessary, because the facade and this package count and spell things differently:
bandis 0-based upstream and 1-based here. pyramids documents the forwarded selector as "a 0-based raster band index (band0is the first band, not band1)", while digitalearth's publicband=is 1-based everywhere. Forwarded unchanged,band=0— what a facade sends for the first band — was refused on every tier, though not in the same words: the web and HoloViz tiers answeredband -1 is out of range for a 1-band datasetand the 3-D tierSelection bands are 1-based; got 0(round-2 M9). That is the off-by-one reported in #501.variable_nameis this package'svariable. TheMeshDatasetfacade spells the mesh selectorvariable_name;quickmapspells itvariable.intervalis milliseconds; the tiers takefps. The animation facades forward a frame interval, and every digitalearth animation verb takes a rate instead.
The module import is deliberately light — standard library only. Discovery imports every
registered entry point, so a heavy import here would pull a drawing stack into a bare
import pyramids; quickmap and the tier classes are imported inside the callables.
interactive(obj, *, backend='interactive', **kwargs)
#
Render a pyramids object on the HoloViz tier, for plot(backend="interactive").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The |
required |
backend
|
str
|
The backend name the seam passes; defaults to the name this is registered under. |
'interactive'
|
**kwargs
|
Any
|
The keywords pyramids forwarded, in its own vocabulary. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
Any
|
class: |
Any
|
player, or the path the animation was written to. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a forwarded keyword this seam cannot serve, or an unusable band/interval. |
Examples:
- Reached through pyramids, which forwards its own keywords (needs the
interactiveextra, so this one is shown rather than run): - A keyword this seam cannot serve is refused in digitalearth's own words, before any
engine is imported, and says where the capability does live:
>>> from digitalearth.pyramids_backend import interactive >>> try: ... interactive("a-dataset", backend="interactive", rgb_options={}) ... except ValueError as exc: ... print(str(exc).split("— ")[1].split(". ")[0]) a three-band composite is built with Map.rgb_composite, a verb this seam does not call - An animation keyword on a still plot is named rather than ignored, which is what it used to be:
See Also
static: The same seam on the matplotlib tier, which needs no extra.
three_d: The same seam on the PyVista tier.
web: The same seam on the MapLibre tier.
ANIMATION_BACKENDS: Which tiers serve an animate call.
Source code in src/digitalearth/pyramids_backend.py
static(obj, *, backend='static', **kwargs)
#
Render a pyramids object on the matplotlib tier, for plot(backend="static").
This is the tier :mod:digitalearth.static implements, and the one installed with no extra. It
is reached as "static" rather than "matplotlib" because
:meth:pyramids.dataset.Dataset.plot branches on if backend != "matplotlib" and takes its
own cleopatra path before consulting the plot-backend registry — an entry point registered under
that name could never be reached, so ds.plot(backend="matplotlib") stays cleopatra's and this
tier gets its own name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The pyramids object the facade was called on. |
required |
backend
|
str
|
The backend name the seam passes; defaults to the name this is registered under. |
'static'
|
**kwargs
|
Any
|
The keywords pyramids forwarded, in its own vocabulary. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Any
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a forwarded keyword this seam cannot serve, an unusable band, or an
animation call — this tier is outside :data: |
Examples:
- Reached through pyramids, which needs no extra for this tier. The figure is this package's
own 8x8 default rather than the one cleopatra sizes from the data, which is the visible
sign that the call arrived here and not on
ds.plot()'s own path: - What comes back is the tier's own scene, so its methods carry on from the plot call and its layers are addressable by id:
- The facade's band index is 0-based and this package's is 1-based, and the shift happens
here — see :data:
BAND_ORIGIN_SHIFT. Thatband=0draws at all, in the examples above, is the demonstration: through pyramids' import-by-name fallback the index arrives unshifted and the tier answersband -1 is out of range, so the entry point is what makes the call correct rather than merely tidier.
See Also
interactive: The same seam on the HoloViz tier.
three_d: The same seam on the PyVista tier.
web: The same seam on the MapLibre tier.
ANIMATION_BACKENDS: The tiers whose animation this seam drives, which does not include this
one — :data:_UNANIMATABLE carries the reason.
BAND_ORIGIN_SHIFT: The offset between the facade's band index and this package's.
Source code in src/digitalearth/pyramids_backend.py
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 | |
three_d(obj, *, backend='3d', **kwargs)
#
Render a pyramids object on the PyVista tier, for plot(backend="3d").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The pyramids object the facade was called on. |
required |
backend
|
str
|
The backend name the seam passes; defaults to the name this is registered under. |
'3d'
|
**kwargs
|
Any
|
The keywords pyramids forwarded, in its own vocabulary. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Any
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a forwarded keyword this seam cannot serve, an unusable band, or an
animation request — the 3-D tier's animation verbs cannot be driven from a plot call
(see :data: |
Examples:
- Reached through pyramids (needs the
3dextra, so this one is shown rather than run): - An animation request is refused by name, and names the two verbs that do animate a scene:
- A band that is not a 0-based index is refused here rather than by the reader, far away:
See Also
static: The same seam on the matplotlib tier, which needs no extra. interactive: The same seam on the HoloViz tier, which does serve an animation. web: The same seam on the MapLibre tier. ANIMATION_BACKENDS: Why this tier is absent from it.
Source code in src/digitalearth/pyramids_backend.py
web(obj, *, backend='web', **kwargs)
#
Render a pyramids object on the MapLibre tier, for plot(backend="web").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The pyramids object the facade was called on. |
required |
backend
|
str
|
The backend name the seam passes; defaults to the name this is registered under. |
'web'
|
**kwargs
|
Any
|
The keywords pyramids forwarded, in its own vocabulary. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Any
|
class: |
Any
|
was written to. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a forwarded keyword this seam cannot serve, an unusable band, or an
animation call that named no |
Examples:
- Reached through pyramids (needs the
webextra, so this one is shown rather than run): - This tier animates only to a file, so an animation with no destination says what to pass:
- Animating a single raster's bands is refused: this seam steps through a stack's members:
See Also
static: The same seam on the matplotlib tier, which needs no extra. interactive: The same seam on the HoloViz tier, whose animation needs no destination. three_d: The same seam on the PyVista tier. BAND_ORIGIN_SHIFT: The offset between the facade's band index and this package's.