Interactive maps (HoloViz)#
InteractiveMap is the pan/zoom/hover backend: a Bokeh canvas with a display CRS and a list of layers it can
re-order, hide, restyle and remove after they are drawn. It is the interactive sibling of the matplotlib
Map — the same method names wherever the two can draw the same thing — and needs the
interactive extra (pip install 'digitalearth[interactive]') only when a builder or render method is
actually called; importing the module works without it.
from digitalearth.interactive import InteractiveMap
m = InteractiveMap(crs=3857, tiles="CartoLight")
m.field(dataset, cmap="terrain")
m.points(stations, name="obs")
m.coastlines()
m.save("map.html")
Every input is reprojected to the display CRS through pyramids before an element is built, so the Bokeh
layers are already in the display CRS (EPSG:3857 by default — the only CRS Bokeh tile basemaps render). The
rendering itself is HoloViews/GeoViews/Datashader; styling keywords (cmap, clim, alpha, …) are handed
straight to the engine, which is why they are documented there rather than here.
What this tier is for#
Exploration: a dataset you pan into, a cell you click to pull a time series, an area you draw to crop, a million points shaded server-side so they cost the same as a thousand. Anything that must come back as a file — a vector export, a print-quality figure — belongs to the matplotlib tier; this one saves interactive HTML and headless PNG.
The layer list#
A builder records a layer addressed by the name= you gave it (or a generated id), and returns the map so the
calls chain. layer_ids lists them in draw order, and move_layer, remove_layer, replace_layer and
set_visible work on that list afterwards, so a figure can be rearranged without being rebuilt. Layers sit in
bands — underlay, reference, data, overlay — so a basemap stays under the data and a graticule stays
over it however the calls were ordered. figure_spec is the whole map as a value, the description the other
tiers read back.
The layer control#
layer_control() builds a Panel widget — one visibility toggle per layer, an opacity slider and a basemap
switch — and returns the map; the widget itself is read back through layer_control_panel. The control is
keyed by layer id, not by the position a layer held when it was built, so toggling and removal keep
working after the overlay is re-stacked. reorder=True adds a ▲/▼ button per layer that moves it within
its band live. The basemap switch is Web-Mercator-only (Bokeh renders tiles in EPSG:3857); named outright on a
non-Mercator map it is refused, left at the default it is quietly dropped.
m = InteractiveMap().field(dataset).points(stations)
m.layer_control(controls=("visibility", "opacity"), reorder=True)
m.layer_control_panel # the Panel object to display
Every widget event — the dashboard's and the layer control's alike — goes through one reconcile that re-styles only the layers a value reaches and reuses every other element untouched, so a slider tick does not rebuild the map.
Big data#
rasterize and datashade aggregate millions of rows into a server-rendered density image that
re-aggregates on every pan/zoom. rasterize keeps a Bokeh colorbar and client-side colour-mapping, so it can
pin a frozen colour scale with clim/cnorm — a rasterized layer then shares one range with a
neighbouring field, and cnorm="eq_hist" reaches Bokeh's EqHistColorMapper (which takes explicit limits,
where Datashader refuses a span under eq-hist).
Clicking, drawing and brushing#
A live kernel or server is what makes these round-trip to Python; in a saved HTML they degrade to plain hover.
on_tap/tap_profile pull a value (or a DatasetCollection time series) at the clicked cell. draw() adds a
box/polygon/point/freehand tool and drawn_geometry/aoi_crop read the sketch back in pyramids' CRS to
drive a crop. cross_filter links a selection across panels and hands the selected rows back.
Live data#
live() adds a streaming layer backed by a HoloViews Pipe (each push replaces the data) or a
Buffer (each push appends, keeping the last length rows). Only the changed glyphs redraw — the IN-2
reconcile applied to a feed — so a moving vehicle or a sensor stream does not rebuild the map. Reach the
stream with live_stream(id) and feed it with push(id, data); the data is in the display CRS, and the
repaint reaches the browser under a live kernel/server.
m = InteractiveMap().live(kind="points", name="cars")
m.push("cars", positions_df) # positions_df: x/y in the display CRS
Themes#
theme() sets one Bokeh theme for every render of the map — a built-in name ("dark_minimal", "night_sky",
…) or a bokeh.themes.Theme — instead of threading bgcolor through **opts at every call.
Dashboards#
dashboard() wraps the map and reactive widgets into a Panel app; serve() marks it servable and save_app()
bakes the widget states into a standalone HTML file. A pyramids-backed app must be served, not converted to
WASM — GDAL does not run in the browser. share() syncs the view into the URL under a running server.
digitalearth.interactive.map.InteractiveMap
#
Bases: RasterMixin, VectorMixin, BigDataMixin, TemporalMixin, DecorationMixin, LegendMixin, InteractionMixin, LiveMixin, ProjectionMixin, AnimationMixin, DashboardMixin, InteractiveMapBase
Interactive 2-D web map: pan/zoom/hover Bokeh layers built from pyramids data.
The interactive sibling of the static :class:~digitalearth.static.map.Map: raster/vector builders
turn pyramids objects into GeoViews elements (reprojected to the display CRS through pyramids first),
register them as layers, and render()/save() compose them into one overlay. Needs the optional
interactive extra (pip install 'digitalearth[interactive]') only when a builder/render method
is actually called — importing this module works without it.
Examples:
- Importing and constructing needs no HoloViz engine:
- Layers register in overlay order and the builders chain:
- With the
interactiveextra installed, a raster becomes a pan/zoom web map:
See Also
digitalearth.static.map.Map: the static matplotlib sibling of this scene. digitalearth.three_d.scene3d.Scene3D: the true-3D (PyVista) sibling.
Source code in src/digitalearth/interactive/map.py
drawn_geometry
property
#
The geometry drawn via :meth:draw, as a display-CRS bbox/dict (or None).
For a box this is (xmin, ymin, xmax, ymax) in the display CRS — ready to feed
Dataset.crop (pyramids). Returns None before anything is drawn. Needs a live kernel
for the stream to have captured anything.
Returns:
| Type | Description |
|---|---|
Any
|
The drawn geometry, or |
layer_control_panel
property
#
The Panel layer manager :meth:layer_control built, or None when none has been built.
:meth:layer_control returns the map, the way every other builder on both 2-D tiers does (#264), so
the object a caller displays is held on the map and read back here — the same place the static tier
keeps its fig/ax and this tier keeps its layers. Read-only on purpose: a panel this map
did not build is not this map's control.
Returns:
| Type | Description |
|---|---|
Any
|
A |
Any
|
layer hides/shows it, the opacity slider sets its alpha, and the basemap |
Any
|
tiles underneath. |
Any
|
it rather than stacking a second control. |
Examples:
- The control is reached through the map the builder returned:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().field(dem).layer_control() # doctest: +SKIP >>> m.layer_control_panel is None # doctest: +SKIP False
layer_ids
property
#
The ids of the layers this map draws, in draw order, bottom first.
Returns:
| Type | Description |
|---|---|
list[str]
|
One id per described layer. A layer the caller named carries that name, with surrounding |
list[str]
|
whitespace removed; an unnamed one gets a generated id counting the layers of its kind — |
list[str]
|
|
list[str]
|
It counted the map until review R2-M10, while this sentence already said otherwise |
list[str]
|
(review R2-L2). |
Examples:
- A named layer keeps its name; an unnamed one is numbered after what it is:
- Draw order, not call order: a layer in the reference band added second is listed first, because that is where it is drawn:
- A map that has drawn nothing has no ids:
figure_spec
property
#
What the map draws, as data: its layers, their sources and the view.
Returns:
| Name | Type | Description |
|---|---|---|
A |
FigureSpec
|
class: |
FigureSpec
|
tree in draw order and whose sources are what each builder was given. |
|
FigureSpec
|
It carries only the half of the styling that travels |
|
FigureSpec
|
(:func: |
|
FigureSpec
|
reduction, a tile provider, a timestamp, a tuple such as a dash pattern and an array are held |
|
FigureSpec
|
beside the layer instead (:func: |
|
FigureSpec
|
with what the description alone can say. A |
|
FigureSpec
|
those — it comes back from JSON as itself, so it is described (#330). |
|
FigureSpec
|
A map built from a GeoDataFrame or a dataset already in memory can be handed straight to a |
|
FigureSpec
|
renderer, but not written: |
|
FigureSpec
|
process's memory would be unreadable everywhere else. Give a builder a path or a URL to get a |
|
FigureSpec
|
figure that can be stored. |
Examples:
- The panel names the layers it draws, and each layer says what it is:
- A builder describes its layer by the engine-neutral kind and the recipe it drew by, and
files what it drew as the layer's source:
>>> import geopandas as gpd # doctest: +SKIP >>> from shapely.geometry import Point # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> gdf = gpd.GeoDataFrame(geometry=[Point(4.9, 52.4)], crs=4326) # doctest: +SKIP >>> figure = InteractiveMap().points(gdf).figure_spec # doctest: +SKIP >>> layer = figure.layers.get("points-1") # doctest: +SKIP >>> layer.kind, layer.symbology.props["via"], layer.source_id # doctest: +SKIP ('points', 'geometry', 'points-1')
viewport
property
#
Where the map is looking, as a value — including the region it has been framed on.
Returns:
| Type | Description |
|---|---|
Viewport
|
The view :class: |
Viewport
|
carrying the region :meth: |
Viewport
|
centre or zoom: this tier is framed by an extent, not by a camera position. |
field(data, *, band=DEFAULT_BAND, cmap=None, limits=None, scheme=None, k=None, opacity=UNSET, colorbar=True, clabel=None, name=None, visible=True, **opts)
#
Add a colour-mapped raster layer with hover readout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
A pyramids |
required |
band
|
int
|
1-based band to render. |
DEFAULT_BAND
|
cmap
|
str | None
|
Colormap name; |
None
|
limits
|
tuple[float, float] | None
|
Optional |
None
|
scheme
|
Any | None
|
Colour the band class by class rather than along a ramp. A named graduated scheme
( |
None
|
k
|
int | None
|
How many classes a named graduated scheme cuts; |
None
|
opacity
|
Maybe[float]
|
Layer opacity in |
UNSET
|
colorbar
|
bool
|
Whether to draw a colorbar. |
True
|
clabel
|
str | None
|
Colorbar label; |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Examples:
- Render a DEM as a pan/zoom raster with explicit colour limits:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().field(dem, cmap="terrain", limits=(0, 60)) # doctest: +SKIP >>> len(m.layers) # doctest: +SKIP 1 - Classify a band into three equal-interval classes, and read the edges its colour encoding
records — the ones a figure drawn on another tier keeps:
>>> import numpy as np # doctest: +SKIP >>> from digitalearth.base.sources import get_source # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> src = get_source( # doctest: +SKIP ... np.arange(10.0).reshape(2, 5), x=np.arange(5.0), y=np.array([1.0, 0.0]) ... ) >>> m = InteractiveMap().field(src, scheme="equal_interval", k=3, name="dem") # doctest: +SKIP >>> m.figure_spec.layers.get("dem").symbology.encoding("color").scale.breaks # doctest: +SKIP (0.0, 3.0, 6.0, 9.0) - Draw a band of class codes as categories, one colour per code:
>>> import numpy as np # doctest: +SKIP >>> from digitalearth.base.sources import get_source # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> src = get_source( # doctest: +SKIP ... np.array([[1.0, 1.0, 2.0], [3.0, 3.0, 2.0]]), ... x=np.array([0.0, 1.0, 2.0]), ... y=np.array([1.0, 0.0]), ... ) >>> m = InteractiveMap().field(src, scheme="categorical", name="landcover") # doctest: +SKIP >>> scale = m.figure_spec.layers.get("landcover").symbology.encoding("color").scale # doctest: +SKIP >>> scale.categories, [scale.color_for(code) for code in scale.categories] # doctest: +SKIP ((1, 2, 3), ['#1f77b4', '#ff7f0e', '#2ca02c'])
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a |
Source code in src/digitalearth/interactive/builders/raster.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
quadmesh(data, *, band=DEFAULT_BAND, cmap=None, clabel=None, name=None, visible=True, **opts)
#
Add a quadrilateral-mesh raster layer (handles non-uniform / curvilinear coordinates).
Unlike :meth:field (regular grid), a QuadMesh draws each cell from its coordinate
arrays, so irregularly spaced or 2-D (curvilinear) coordinates render without resampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
A pyramids |
required |
band
|
int
|
1-based band to render. |
DEFAULT_BAND
|
cmap
|
str | None
|
Colormap name; |
None
|
clabel
|
str | None
|
Colorbar label; |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Examples:
- Draw an irregular grid without resampling to axis-aligned:
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Source code in src/digitalearth/interactive/builders/raster.py
rgb(data, *, bands=DEFAULT_COMPOSITE_BANDS, limits=None, name=None, visible=True, **opts)
#
Add a true-colour composite from three raster bands (2–98 % percentile stretch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
A pyramids multiband |
required |
bands
|
Sequence[int]
|
The three 1-based band indices composing |
DEFAULT_COMPOSITE_BANDS
|
limits
|
ChannelLimits | None
|
Optional frozen |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Examples:
- Compose three bands of a satellite stack into true colour:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> stack = Dataset.read_file("sentinel.tif") # doctest: +SKIP >>> m = InteractiveMap().rgb(stack, bands=(4, 3, 2)) # doctest: +SKIP >>> [d.name for d in m.layers[0].vdims] # doctest: +SKIP ['R', 'G', 'B']
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Source code in src/digitalearth/interactive/builders/raster.py
contours(dataset, *, band=DEFAULT_BAND, levels=None, interval=None, filled=False, name=None, visible=True, **opts)
#
Trace iso-value lines of a raster band, or fill the bands between them.
The three keywords the Tier-2 contract declares — levels, interval and filled — on the
one method that answers to the name, so a call written against the web or static tier runs here
unchanged (#262). This tier also had a second method, filled_contours, for what filled=True
says here; it was deleted in review M3, and interval= used to fall through **opts to
HoloViews, which refused it as an unknown style option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
A pyramids |
required |
band
|
int
|
1-based band to contour. |
DEFAULT_BAND
|
levels
|
Any
|
Contour levels — an int (count) or explicit sequence; |
None
|
interval
|
float | None
|
Spacing between levels — one level every N, in the band's own units. Resolved
against the band when the layer is drawn, because it is the band that decides which
multiples of the spacing lie inside it, and only the ones strictly inside are traced: a
level on an extreme draws the frame's edge or nothing. The arithmetic is
:func: |
None
|
filled
|
bool
|
Fill the bands between the levels instead of drawing the levels as lines. It is also
what the layer's kind records — |
False
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
when both |
Examples:
- Contour a raster at five levels:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().contours(dem, levels=5) # doctest: +SKIP >>> len(m.layers) # doctest: +SKIP 1 - One level every 100 m, filled, from the same method:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().contours(dem, interval=100, filled=True) # doctest: +SKIP >>> type(m.layers[0]).__name__ # doctest: +SKIP 'Polygons'
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
See Also
digitalearth.base.levels.levels_every: the shared interval-to-levels arithmetic.
Source code in src/digitalearth/interactive/builders/raster.py
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | |
spaghetti(collection, *, band=DEFAULT_BAND, name=None, visible=True, **opts)
#
Overlay each member of a DatasetCollection as line contours (ensemble spaghetti).
Each member gets a distinct colour from a cycling palette so the strands are
distinguishable, unless the caller passes an explicit color/cmap in opts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Any
|
A pyramids |
required |
band
|
int
|
1-based band contoured in every member. |
DEFAULT_BAND
|
name
|
str | None
|
The caller's own name for the layers, used as their ids and labels; |
None
|
visible
|
bool
|
Whether the members are drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to each member's contour element. An
explicit |
{}
|
Examples:
- Overlay a three-member ensemble as spaghetti contours:
>>> from pyramids.dataset.collection import DatasetCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dc = DatasetCollection.from_files(["examples/data/acc4000.tif"] * 3) # doctest: +SKIP >>> m = InteractiveMap().spaghetti(dc, levels=4) # doctest: +SKIP >>> len(m.layers) # doctest: +SKIP 3
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable) — one contour layer registered per member. |
Source code in src/digitalearth/interactive/builders/raster.py
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | |
large_image(dataset, *, band=DEFAULT_BAND, max_pixels=4000000, dynamic=True, cmap=None, name=None, visible=True, **opts)
#
Add a large raster / COG by loading only the viewport at a decimated overview (DI.14).
The raster analogue of the vector Datashader path: instead of materialising a multi-GB raster,
it reads only the visible window at a suitable overview via pyramids and re-reads on pan/
zoom. Cloud-native partial reads for remote COGs over /vsicurl/ come for free.
Every frame is a read through the data tier (#297): the window, the canvas and the budget are a
:class:~digitalearth.base.spec.RenderTarget request, and
:class:~digitalearth.base.sources.view.SourceView answers it — snapping the window to source pixel
edges, never asking for more cells than the window holds, masking what is missing, and drawing an
empty frame for a window off the data. A raster in another CRS is read through pyramids'
Dataset.warped_view, so each frame warps only its own window rather than the whole raster once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
A pyramids |
required |
band
|
int
|
1-based band to read. |
DEFAULT_BAND
|
max_pixels
|
int
|
Cell budget per rendered frame. The canvas follows the map's own width and height within it, so a wide map reads a wide window rather than a square one. |
4000000
|
dynamic
|
bool
|
Re-read the viewport on pan/zoom via a |
True
|
cmap
|
str | None
|
Colormap; |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
AttributeError
|
when |
Examples:
dynamic=Falsereads one frame of the whole raster — deterministic, and the one form that works with no live server behind it. A raster already under the budget comes back whole, so the budget only ever caps what is materialised:>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> (dem.rows, dem.columns) # doctest: +SKIP (13, 14) >>> m = InteractiveMap().large_image(dem, dynamic=False) # doctest: +SKIP >>> m.layers[0].dimension_values(2, flat=False).shape # doctest: +SKIP (13, 14)- The default
dynamic=Trueregisters a viewport-driven layer instead, carrying two streams — aRangeXYthat re-reads the window from the axes ranges on every pan/zoom, and aPlotSizethat re-reads at the new resolution on a browser-window resize (IN-6): - A raster without pyramids' windowed-read surface is refused by name, rather than being quietly read whole:
Source code in src/digitalearth/interactive/builders/raster.py
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
points(features, *, column=None, scheme=None, k=5, size=UNSET, cmap='viridis', opacity=None, rasterize='auto', big_data_threshold=None, name=None, visible=True, **opts)
#
Add a point layer, optionally coloured by an attribute column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A pyramids |
required |
column
|
str | None
|
The column colouring the points (also shown on hover). The Core spelling, and the one
|
None
|
opacity
|
float | None
|
How opaque the layer is, in |
None
|
scheme
|
Any | None
|
Optional classification scheme for |
None
|
k
|
int
|
Number of classes a named |
5
|
size
|
Maybe[float]
|
Marker size in screen pixels — the one thing |
UNSET
|
cmap
|
str
|
Colormap used when |
'viridis'
|
rasterize
|
Any
|
|
'auto'
|
big_data_threshold
|
int | None
|
Row count above which |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. Anything written here wins
over the option a |
{}
|
Note
rasterize="auto" counts the rows, whether features is a loaded collection or a path.
A path used to be measured as a string — a layer named by a 25-character path was reported as
25 features when the file held 10, so a ten-row layer routed through Datashader on the strength
of its filename (#316). pyramids now answers the count without reading the geometry
(FeatureCollection.feature_count, serapeum-org/pyramids#1200, shipped in 0.65.0), so naming a
file still costs no open and the two spellings of one input agree. The routing log line names the
number the decision used, so a surprising one is visible rather than silent.
Examples:
- Colour gauging stations by an attribute column:
>>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> fc = FeatureCollection.read_file("tests/data/points.geojson") # doctest: +SKIP >>> m = InteractiveMap().points(fc, column="fid") # doctest: +SKIP >>> [d.name for d in m.layers[0].vdims] # doctest: +SKIP ['fid']
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
Source code in src/digitalearth/interactive/builders/vector.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | |
lines(features, *, column=None, scheme=None, k=5, cmap='viridis', width=None, opacity=None, name=None, visible=True, **opts)
#
Add a line layer (LineString / MultiLineString features), optionally coloured by a column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A pyramids |
required |
column
|
str | None
|
The column colouring the lines (also shown on hover); |
None
|
scheme
|
Any | None
|
Optional classification of |
None
|
k
|
int
|
Number of classes a named |
5
|
cmap
|
str
|
Colormap used when |
'viridis'
|
width
|
float | None
|
Line width in screen pixels; |
None
|
opacity
|
float | None
|
How opaque the layer is, in |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. Anything written here wins
over the option a |
{}
|
Examples:
- Draw river reaches as an interactive line layer:
>>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> reaches = FeatureCollection.read_file("reaches.geojson") # doctest: +SKIP >>> InteractiveMap().lines(reaches).save("reaches.html").name # doctest: +SKIP 'reaches.html'
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
Source code in src/digitalearth/interactive/builders/vector.py
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | |
polygons(features, *, column=None, scheme=None, k=5, cmap='viridis', opacity=None, rasterize='auto', big_data_threshold=None, name=None, visible=True, **opts)
#
Add a polygon layer — outlines, a continuous fill, or classified by an attribute column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A pyramids |
required |
opacity
|
float | None
|
How opaque the layer is, in |
None
|
column
|
str | None
|
Optional column filling the polygons (also shown on hover); |
None
|
scheme
|
Any | None
|
Optional classification of |
None
|
k
|
int
|
Number of classes a named |
5
|
cmap
|
str
|
Colormap used when |
'viridis'
|
rasterize
|
Any
|
|
'auto'
|
big_data_threshold
|
int | None
|
Row count above which |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Note
rasterize="auto" counts the rows, whether features is a loaded collection or a path.
A path used to be measured as a string — a layer named by a 25-character path was reported as
25 features when the file held 10, so a ten-row layer routed through Datashader on the strength
of its filename (#316). pyramids now answers the count without reading the geometry
(FeatureCollection.feature_count, serapeum-org/pyramids#1200, shipped in 0.65.0), so naming a
file still costs no open and the two spellings of one input agree. The routing log line names the
number the decision used, so a surprising one is visible rather than silent.
Examples:
- Outline catchment polygons over a basemap:
>>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> basins = FeatureCollection.read_file("basins.geojson") # doctest: +SKIP >>> InteractiveMap().polygons(basins).basemap().save("m.html").name # doctest: +SKIP 'm.html'
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
KeyError
|
when |
ImportError
|
when the layer routes through Datashader ( |
Warns:
| Type | Description |
|---|---|
UserWarning
|
when a classified call ( |
Source code in src/digitalearth/interactive/builders/vector.py
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 | |
choropleth(features, column, *, scheme=None, k=5, cmap='viridis', opacity=None, clim=None, name=None, visible=True, **opts)
#
Add a choropleth — polygons filled and coloured by column (hover shows the value).
A thin colour-by-attribute :meth:polygons, mirroring the static Map.choropleth. Pass
scheme="categorical" to colour an unordered attribute by distinct value instead of a continuous
ramp (DC.8), or a graduated scheme ("quantiles"/"equal_interval"/"fisher_jenks"/…)
to classify a numeric column into k flat classes. Either way the categories or class edges are
published on the layer's own colour encoding, as the :class:~digitalearth.base.spec.scale.Scale it
was classified through — which is what :meth:colorbar and :meth:legend hang their key on (order
24) and what :meth:~digitalearth.base.spec.legend.LegendSpec.from_scale derives a swatch list from.
They are recorded on last_breaks as well, which keeps the caller's own category values (the scale
colours by their string form) and stays the raw-numbers accessor the web tier also publishes.
Graduated classification goes through :class:~digitalearth.base.spec.scale.Scale — the one place
every tier reaches the classifier — so the same column/scheme/k yields the same breaks on
every tier. Note the default scheme still differs: this interactive tier (like the static
Map.choropleth) defaults to a continuous ramp, whereas the web choropleth is
graduated-by-default ("quantiles"). Pass scheme explicitly for identical classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A pyramids |
required |
column
|
str
|
The column driving the fill colour (required); numeric for the continuous ramp, or any
hashable value for |
required |
scheme
|
str | None
|
|
None
|
k
|
int
|
Number of classes for a graduated |
5
|
cmap
|
str
|
Colormap name (a qualitative map such as |
'viridis'
|
opacity
|
float | None
|
How opaque the layer is, in |
None
|
clim
|
tuple[float, float] | None
|
Optional |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Examples:
- Fill polygons by a population column with fixed colour limits:
>>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> admin = FeatureCollection.read_file("admin.geojson") # doctest: +SKIP >>> m = InteractiveMap().choropleth(admin, "pop", clim=(0, 1e6)) # doctest: +SKIP >>> [d.name for d in m.layers[0].vdims] # doctest: +SKIP ['pop']
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
ValueError
|
when a graduated |
Source code in src/digitalearth/interactive/builders/vector.py
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 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 | |
hexbin(features, *, gridsize=30, aggregator='mean', column=None, cmap='viridis', name=None, visible=True, **opts)
#
Add an equal-area hex-bin density layer (honest no-overplot density, recipe I7).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A point |
required |
gridsize
|
int
|
Number of hexagons across — higher is finer. |
30
|
aggregator
|
str
|
Per-bin reducer ( |
'mean'
|
column
|
str | None
|
Value column aggregated per bin (required for non- |
None
|
cmap
|
str
|
Colormap name. |
'viridis'
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/builders/vector.py
kde(features, *, filled=True, cmap='viridis', name=None, visible=True, **opts)
#
Add a 2-D kernel-density layer of point positions (parity with Map.kde, recipe I7).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A point |
required |
filled
|
bool
|
Fill the density bands ( |
True
|
cmap
|
str
|
Colormap name. |
'viridis'
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/builders/vector.py
flow(nodes, edges, *, weight=None, name=None, visible=True, **opts)
#
Spatial-flow alias of :meth:graph mirroring Map.sankey's framing (DI.15).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
Any
|
A point |
required |
edges
|
Any
|
|
required |
weight
|
str | None
|
Optional flow-magnitude column. |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Forwarded to :meth: |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/builders/vector.py
vectorfield(u, v, *, band=DEFAULT_BAND, density=1.0, color_by='magnitude', cmap='viridis', name=None, visible=True, **opts)
#
Add a u/v vector field as interactive arrows (parity with Map.quiver, recipe I6).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Any
|
Eastward-component |
required |
v
|
Any
|
Northward-component |
required |
band
|
int
|
1-based band read from each component. |
DEFAULT_BAND
|
density
|
float
|
Keep-fraction in |
1.0
|
color_by
|
str | None
|
|
'magnitude'
|
cmap
|
str
|
Colormap used when |
'viridis'
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Source code in src/digitalearth/interactive/builders/vector.py
barbs(u, v, *, band=DEFAULT_BAND, density=1.0, name=None, visible=True, **opts)
#
Add wind barbs of a u/v field — matplotlib backend only (parity with Map.barbs).
gv.WindBarbs has no Bokeh renderer, so barbs are a static matplotlib layer; this logs
that they are non-interactive rather than silently producing an empty Bokeh layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Any
|
Eastward-component |
required |
v
|
Any
|
Northward-component |
required |
band
|
int
|
1-based band read from each component. |
DEFAULT_BAND
|
density
|
float
|
Keep-fraction in |
1.0
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ImportError
|
when the installed GeoViews has no |
ValueError
|
when |
Source code in src/digitalearth/interactive/builders/vector.py
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 | |
streamlines(u, v, *, band=DEFAULT_BAND, density=1.0, name=None, visible=True, **opts)
#
Add streamlines of a u/v field via the matplotlib backend (parity with Map.streamplot).
Bokeh has no streamline integrator, so streamlines render through HoloViews' matplotlib
backend (a static layer in the saved PNG). The element is built so save("x.png") works;
it is logged as non-interactive rather than emitting an empty Bokeh layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Any
|
Eastward-component |
required |
v
|
Any
|
Northward-component |
required |
band
|
int
|
1-based band read from each component. |
DEFAULT_BAND
|
density
|
float
|
Keep-fraction in |
1.0
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Source code in src/digitalearth/interactive/builders/vector.py
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 | |
trimesh(data, *, value_column=None, rasterize='auto', big_data_threshold=None, cmap='viridis', name=None, visible=True, **opts)
#
Add an unstructured triangular mesh (parity with Map.tricontour/tripcolor, recipe I7).
Connectivity comes from one of two sources, both pyramids-fed:
- a true UGRID mesh (
pyramids.netcdf.ugrid.Mesh2d— anything exposingnode_x/node_y/fan_triangles): nodes + triangles are taken straight off it, no triangulation needed; - a point
FeatureCollection: Delaunay-triangulated locally withmatplotlib.tri(matplotlib is not a forbidden GIS engine), mirroring the statictri*path.
Above big_data_threshold faces the mesh auto-rasterizes to a density image (logged).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
A UGRID-mesh object or a point |
required |
value_column
|
str | None
|
Node-value column (for the FeatureCollection path) driving the colour. |
None
|
rasterize
|
Any
|
|
'auto'
|
big_data_threshold
|
int | None
|
Face count above which |
None
|
cmap
|
str
|
Colormap name. |
'viridis'
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
TypeError
|
when |
Examples:
- Delaunay-triangulate scattered points; the nodes carry the value column:
>>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> fc = FeatureCollection.read_file("tests/data/points.geojson") # doctest: +SKIP >>> m = InteractiveMap().trimesh(fc, value_column="fid") # doctest: +SKIP >>> len(m.layers[0].nodes) == len(fc) # doctest: +SKIP True >>> [d.name for d in m.layers[0].nodes.vdims] # doctest: +SKIP ['fid'] - A UGRID mesh brings its own connectivity, so nothing is triangulated locally — its
four nodes and two faces come through as they are:
>>> import numpy as np # doctest: +SKIP >>> from pyramids.netcdf.ugrid import Connectivity, Mesh2d # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> mesh = Mesh2d( # doctest: +SKIP ... node_x=np.array([0.0, 1.0, 0.5, 1.5]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=Connectivity( ... data=np.array([[0, 1, 2], [1, 3, 2]]), ... fill_value=-1, ... cf_role="face_node_connectivity", ... original_start_index=0, ... ), ... ) >>> len(InteractiveMap().trimesh(mesh).layers[0].nodes) # doctest: +SKIP 4 - Lowering the cutoff routes the same mesh through Datashader instead, and the
density image is styled (and recorded) with the
cmapthat was asked for:>>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> m = InteractiveMap() # doctest: +SKIP >>> m = m.trimesh(fc, big_data_threshold=1, cmap="magma") # doctest: +SKIP >>> m.layer_styles[0]["common"]["cmap"] # doctest: +SKIP 'magma' >>> m.layer_styles[0]["common"]["colorbar"] # doctest: +SKIP True
Source code in src/digitalearth/interactive/builders/vector.py
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 | |
labels(features, column, *, crs=4326, name=None, visible=True, **opts)
#
Add per-feature text labels from a point FeatureCollection column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A pyramids |
required |
column
|
str
|
The attribute column whose values are drawn as labels. |
required |
crs
|
Any
|
Unused when |
4326
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
Source code in src/digitalearth/interactive/decoration/decoration.py
text(lon, lat, s, *, crs=4326, name=None, visible=True, **opts)
#
Add a single text annotation at (lon, lat) (reprojected to the display CRS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
Any
|
X / longitude of the label anchor, in |
required |
lat
|
Any
|
Y / latitude of the label anchor, in |
required |
s
|
str
|
The text to draw. |
required |
crs
|
Any
|
CRS of |
4326
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/decoration/decoration.py
timecube(collection, *, kdim='time', labels=None, band=DEFAULT_BAND, cmap=None, clim=None, colorbar=True, name=None, visible=True, **opts)
#
Render a DatasetCollection as an interactive time-slider map.
Builds an hv.DynamicMap whose frame(t) constructs an I1 hv.Image from the t-th
member; redim.values drives a Bokeh slider. The colour range is frozen across frames so
the colorbar is identical on the first and last frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Any
|
A pyramids |
required |
kdim
|
str
|
Slider dimension name. |
'time'
|
labels
|
Sequence | None
|
Optional per-member labels (e.g. datetimes) shown on the slider instead of the integer index; must match the member count. |
None
|
band
|
int
|
1-based band rendered in every frame. |
DEFAULT_BAND
|
cmap
|
str | None
|
Colormap name; |
None
|
clim
|
tuple[float, float] | None
|
Frozen |
None
|
colorbar
|
bool
|
Whether to draw a colorbar. |
True
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to every frame. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain — one |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Examples:
- Scrub a 3-step collection with a frozen colour range:
>>> from pyramids.dataset.collection import DatasetCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dc = DatasetCollection.from_files(["a.tif", "b.tif"]) # doctest: +SKIP >>> m = InteractiveMap().timecube(dc, cmap="inferno") # doctest: +SKIP >>> [d.name for d in m.layers[0].kdims] # doctest: +SKIP ['time'] - Label the slider with real datetimes:
>>> import datetime as dt # doctest: +SKIP >>> from pyramids.dataset.collection import DatasetCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dc = DatasetCollection.from_files(["a.tif", "b.tif"]) # doctest: +SKIP >>> stamps = [dt.datetime(2020, 1, 1), dt.datetime(2020, 1, 2)] # doctest: +SKIP >>> m = InteractiveMap().timecube(dc, labels=stamps) # doctest: +SKIP >>> m.save("t.html").name # doctest: +SKIP 't.html'
Source code in src/digitalearth/interactive/temporal/temporal.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
rasterize(layer, *, aggregator='count', column=None, dynamic=True, cmap='viridis', clim=None, cnorm=None, name=None, visible=True, **opts)
#
Add a server-rasterized density layer that re-aggregates on zoom.
Produces a numeric image (Bokeh keeps colorbar + hover + live recolor), aggregating all rows per screen pixel — a million points cost the same as a thousand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Any
|
A HoloViews element or a (Feature)GeoDataFrame (becomes a point layer). |
required |
aggregator
|
Any
|
Reduction name ( |
'count'
|
column
|
str | None
|
The value column aggregated by column-requiring reductions. |
None
|
dynamic
|
bool
|
Re-rasterize on every viewport change (needs a live kernel/server); |
True
|
cmap
|
str
|
Colormap for the rasterized image. |
'viridis'
|
clim
|
tuple[float, float] | None
|
Frozen |
None
|
cnorm
|
str | None
|
Colour normalisation Bokeh applies — |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/builders/bigdata.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | |
datashade(layer, *, cmap='viridis', color_key=None, aggregator='count', column=None, dynamic=True, clim=None, cnorm=None, name=None, visible=True, **opts)
#
Add a fully shaded (RGB) density layer — categorical blends via color_key (DI.2a).
Unlike :meth:rasterize the colour-mapping happens server-side too (no Bokeh colorbar /
live recolor) — use it when categories must blend per pixel, e.g. landcover classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Any
|
A HoloViews element or a (Feature)GeoDataFrame (becomes a point layer). |
required |
cmap
|
str
|
Colormap for continuous shading (ignored when |
'viridis'
|
color_key
|
Any | None
|
|
None
|
aggregator
|
Any
|
Reduction name or Datashader reduction; |
'count'
|
column
|
str | None
|
The value/category column. |
None
|
dynamic
|
bool
|
Re-shade on every viewport change; |
True
|
clim
|
tuple[float, float] | None
|
Frozen |
None
|
cnorm
|
str | None
|
Shade normalisation — |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/builders/bigdata.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
trajectory(features, *, track_column=None, by=None, dynspread=True, cmap='viridis', color_key=None, dynamic=True, clim=None, cnorm=None, name=None, visible=True, **opts)
#
Datashade millions of ordered track points as line density (GPS/AIS, DI.2b).
Point rows are connected into per-track paths (NaN-separated, the Canvas.line recipe)
and aggregated server-side; with by the tracks blend per class via count_cat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A point (Feature)GeoDataFrame whose row order walks each track; reprojected through pyramids first. |
required |
track_column
|
str | None
|
Column identifying the track each point belongs to; |
None
|
by
|
str | None
|
Optional categorical column colouring tracks per class ( |
None
|
dynspread
|
bool
|
Grow isolated pixels so sparse tracks stay visible. |
True
|
clim
|
tuple[float, float] | None
|
Frozen |
None
|
cnorm
|
str | None
|
Shade normalisation — |
None
|
cmap
|
str
|
Colormap for continuous shading (ignored when |
'viridis'
|
color_key
|
Any | None
|
|
None
|
dynamic
|
bool
|
Re-shade on every viewport change; |
True
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Source code in src/digitalearth/interactive/builders/bigdata.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
live(*, kind='points', data=None, buffer=False, length=1000, name=None, visible=True, **opts)
#
Add a live layer backed by a Pipe (replace) or Buffer (append) you push into (IN-17).
The layer is a DynamicMap that re-renders from the stream, so :meth:push updates only its glyphs
rather than rebuilding the map. Needs a live kernel/server for a push to reach the browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
|
'points'
|
data
|
Any
|
The initial data, in the display CRS — a DataFrame ( |
None
|
buffer
|
bool
|
|
False
|
length
|
int
|
The sliding-window size for |
1000
|
name
|
str | None
|
The caller's own layer id/label. |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
HoloViews style options applied to every frame of the live element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. The stream is reached through :meth: |
Self
|
and fed through :meth: |
Raises:
| Type | Description |
|---|---|
ValueError
|
for an unknown |
Examples:
- A point feed starts empty; pushing replaces its data, and the layer is a live
DynamicMap:>>> import pandas as pd # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> import holoviews as hv # doctest: +SKIP >>> m = InteractiveMap().live(kind="points", name="cars") # doctest: +SKIP >>> isinstance(m.layers[-1], hv.DynamicMap) # doctest: +SKIP True >>> m.push("cars", pd.DataFrame({"x": [0.0], "y": [0.0]})) is m # doctest: +SKIP True >>> len(m.live_stream("cars").data) # doctest: +SKIP 1 - A
Buffertails the lastlengthrows across pushes:>>> import pandas as pd # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> start = pd.DataFrame({"x": [0.0], "y": [0.0]}) # doctest: +SKIP >>> m = InteractiveMap().live( # doctest: +SKIP ... kind="points", data=start, buffer=True, length=2, name="track" ... ) >>> m.push("track", pd.DataFrame({"x": [1.0], "y": [1.0]})) # doctest: +SKIP >>> m.push("track", pd.DataFrame({"x": [2.0], "y": [2.0]})) # doctest: +SKIP >>> len(m.live_stream("track").data) # kept the last 2 # doctest: +SKIP 2
Source code in src/digitalearth/interactive/app/live.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
live_stream(layer_id)
#
Return the Pipe/Buffer backing a live layer, to inspect or .send() to directly (IN-17).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str
|
The live layer's id (:attr: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The HoloViews stream — a |
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
Examples:
- The stream a
livelayer was built with is reached by its id, ready to.send()to:>>> import pandas as pd # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> m = InteractiveMap().live(kind="points", name="cars") # doctest: +SKIP >>> stream = m.live_stream("cars") # doctest: +SKIP >>> stream.send(pd.DataFrame({"x": [0.0], "y": [0.0]})) # doctest: +SKIP >>> len(m.live_stream("cars").data) # doctest: +SKIP 1
Source code in src/digitalearth/interactive/app/live.py
push(layer_id, data)
#
Push new data into a live layer — replace (Pipe) or append (Buffer) — and redraw it (IN-17).
A thin, chainable wrapper over the stream's .send(). Needs a live kernel/server for the update to
reach the browser; off-server it still updates the stream's data so the next render() reflects it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str
|
The live layer's id. |
required |
data
|
Any
|
The new data, in the display CRS — a DataFrame for a |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so pushes chain. |
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
Examples:
- Pushing to a
Pipelayer replaces its data, and pushes chain:>>> import pandas as pd # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> m = InteractiveMap().live(kind="points", name="cars") # doctest: +SKIP >>> m.push("cars", pd.DataFrame({"x": [0.0, 1.0], "y": [0.0, 1.0]})) is m # doctest: +SKIP True >>> len(m.live_stream("cars").data) # doctest: +SKIP 2
Source code in src/digitalearth/interactive/app/live.py
tiles(url, *, level='underlay', name=None, visible=True, **opts)
#
Draw raster tiles from a raw XYZ/WMTS URL template beneath the data layers (#268).
The URL-only half of the basemap entry points: a literal {Z}/{X}/{Y} (or {z}/{x}/{y}) tile
template, drawn as a gv.WMTS. For a named provider or a keyed preset use :meth:basemap instead —
the two no longer share one overloaded parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
A raw XYZ/WMTS URL template, e.g. |
required |
level
|
str
|
|
'underlay'
|
name
|
str | None
|
The caller's own name for the layer, used as its id and label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the tile element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Examples:
- Draw a custom XYZ URL template:
Source code in src/digitalearth/interactive/decoration/decoration.py
coastlines(resolution='110m', *, name=None, visible=True, **opts)
#
Add the Natural-Earth coastline on top of the data layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution
|
str
|
Natural-Earth scale — |
'110m'
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the feature element. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Examples:
- Add a medium-resolution coastline on top of the data:
Raises:
| Type | Description |
|---|---|
ValueError
|
when the display CRS is not Web Mercator. |
Source code in src/digitalearth/interactive/decoration/decoration.py
graticule(lon_step=None, lat_step=None, *, spacing=None, name=None, visible=True, **opts)
#
Add a longitude/latitude graticule at the requested spacing (parity with Map.graticule).
The spacing arguments mirror the static Map.graticule(lon_step, lat_step) so the same call
means the same thing on both tiers. GeoViews draws the grid from Natural Earth's pre-cut
graticules_<n> line layers rather than generating meridians on the fly, so only the shipped,
symmetric steps can be honoured: 1, 5, 10, 15, 20 and 30 degrees, with
lon_step == lat_step. Any other request raises instead of being quietly ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon_step
|
float | None
|
Meridian spacing in degrees; one of :data: |
None
|
lat_step
|
float | None
|
Parallel spacing in degrees; must equal |
None
|
spacing
|
float | None
|
One step for both, for a caller who wants a square grid; it overrides the two
above, and warns when it does, because a call that names all three has had two of its
own arguments thrown away (#336). The same keyword the static and web tiers take, so
one call draws one grid on every tier that draws a graticule at all (#324) — but its
value domain is this engine's, not theirs: only the shipped steps listed above are
honoured, so |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id and its label; |
None
|
visible
|
bool
|
Whether the layer is drawn. |
True
|
**opts
|
Any
|
Extra HoloViews style options applied to the grid feature. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Warns:
| Type | Description |
|---|---|
UserWarning
|
when |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Examples:
- A 10-degree graticule instead of the 30-degree default:
Source code in src/digitalearth/interactive/view/projection.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
set_bounds(bounds=None, *, padding=0.0)
#
Frame the map on a region, or on everything it draws.
Bokeh pans and zooms, so before this the view was whatever HoloViews autoranged to and there was no call a caller could make to open the map on a region — the tier had no framing method under any spelling. It still pans: this sets the initial view rather than locking it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Bounds | Sequence[float] | None
|
A :class:
|
None
|
padding
|
float
|
Breathing room around the frame, as a fraction of its own span — |
0.0
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain — which is what the Core declares and what the web |
Self
|
and 3-D tiers already answer. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a sequence that is not four values; when |
Examples:
- Open the map on a region rather than on whatever the data autoranges to:
Source code in src/digitalearth/interactive/view/projection.py
projection(name, **opts)
#
Set the display projection, rendering through the matplotlib backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Any
|
A cartopy-projection name GeoViews resolves internally (e.g. |
required |
**opts
|
Any
|
Reserved for future projection options (currently unused). |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
when a tile basemap was already requested (tiles are Web-Mercator only and cannot compose with a non-Mercator projection). |
ImportError
|
when the |
Source code in src/digitalearth/interactive/view/projection.py
theme(theme)
#
Set the Bokeh theme every render of this map draws under (IN-18).
A dark-mode map used to be expressible only by threading bgcolor through **opts at every
builder call; this records one theme on the map instead, applied to the Bokeh renderer whenever the
map composes (:meth:render, the dashboard widgets, :meth:save). It is a builder, so it chains with
the rest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme
|
Any
|
A Bokeh built-in theme name — one of :data: |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a string that is not one of the built-in theme names. |
Examples:
- A built-in dark theme, set once and kept for every render:
- An unknown name is refused, with the built-ins named:
Source code in src/digitalearth/interactive/core/base.py
hover(*, tooltips=None, formatters=None, layer=None)
#
Configure the Bokeh hover tooltips on a registered layer (DI.7).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tooltips
|
list | None
|
Bokeh |
None
|
formatters
|
dict | None
|
Optional Bokeh tooltip |
None
|
layer
|
int | None
|
Index into :attr: |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
when there is no layer to configure. |
Source code in src/digitalearth/interactive/app/interaction.py
on_tap(callback, *, source=None)
#
Wire a Tap stream to callback and return the resulting DynamicMap (DI.7).
On click the callback receives (x, y) in the display CRS and returns a HoloViews element
(e.g. a side panel). Needs a live kernel/server to round-trip — in static HTML the map renders
without the tap response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable
|
|
required |
source
|
Any
|
The element the tap listens on; defaults to the layer the caller added last — not the one drawn on top, which is a different layer whenever an overlay sits over it. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
when there is no source layer. |
Source code in src/digitalearth/interactive/app/interaction.py
tap_profile(collection, *, source=None, band=DEFAULT_BAND)
#
Click a cell to pull a time series from a DatasetCollection at that point (DI.7).
Returns a DynamicMap whose Tap callback reads each member's value at the clicked cell
(via pyramids nearest_cell) and plots the series — the most-requested interactive feature
over a static map. Needs a live kernel/server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Any
|
A pyramids |
required |
source
|
Any
|
The map layer the tap listens on; defaults to the layer the caller added last, as
:meth: |
None
|
band
|
int
|
1-based band sampled at the clicked cell. |
DEFAULT_BAND
|
Returns:
| Type | Description |
|---|---|
Any
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
when there is no source layer. |
Source code in src/digitalearth/interactive/app/interaction.py
draw(kind='box', *, num_objects=None, name=None, visible=True)
#
Add a draw/edit tool so the user can sketch an area-of-interest (DI.8).
Wraps a HoloViews draw stream around a fresh annotation layer: "box" → BoxEdit,
"poly" → PolyDraw, "point" → PointDraw, "freehand" → FreehandDraw, plus the
two editing tools that move the vertices of existing geometry (IN-8): "poly-edit" →
PolyEdit and "curve-edit" → CurveEdit. Read the result back via :attr:drawn_geometry.
Needs a live kernel/server — static HTML captures nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
|
'box'
|
num_objects
|
int | None
|
Max number of shapes ( |
None
|
name
|
str | None
|
The caller's own name for the annotation layer, used as its id and its label;
|
None
|
visible
|
bool
|
Whether the annotation layer is drawn. |
True
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for an unknown |
Source code in src/digitalearth/interactive/app/interaction.py
aoi_crop(dataset)
#
Crop dataset (in pyramids) to the drawn box and return the clipped raster (DI.8).
Reads the drawn bbox (display CRS) and calls Dataset.crop — the crop itself is pyramids',
this method only reads the drawn coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
A pyramids |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The cropped |
Raises:
| Type | Description |
|---|---|
ValueError
|
when nothing has been drawn yet. |
Source code in src/digitalearth/interactive/app/interaction.py
cross_filter(*panels, selection_mode='union', cross_filter_mode='intersect', index_cols=None, selected_color=None, unselected_color=None, unselected_alpha=0.1, show_regions=True)
#
Link selections across panels so brushing one cross-filters the others (DI.8 / IN-5).
Wraps holoviews.selection.link_selections and — the point of IN-5 — exposes the parameters that
decide how a brush selects and lets the result be read back into Python: selection_expr on the
returned linker is the live predicate, and selection_param(element) hands back the filtered data.
So brushing an interactive map returns data, the same payoff :meth:aoi_crop already gives a drawn
box. Needs a live kernel/server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*panels
|
Any
|
HoloViews elements/overlays to link (defaults to this map's render when empty). |
()
|
selection_mode
|
str
|
How a new box combines with the current selection on one element —
|
'union'
|
cross_filter_mode
|
str
|
How selections combine across elements — |
'intersect'
|
index_cols
|
list | None
|
Columns that identify a row across elements, so a selection in one table highlights
the same records in another; |
None
|
selected_color
|
str | None
|
Colour drawn for selected glyphs; |
None
|
unselected_color
|
str | None
|
Colour drawn for unselected glyphs; |
None
|
unselected_alpha
|
float
|
Opacity of the unselected glyphs, so the selection stands out. |
0.1
|
show_regions
|
bool
|
Draw the selection geometry (the box/lasso) over the data. |
True
|
Returns:
| Type | Description |
|---|---|
Any
|
The |
Any
|
predicate, or |
Examples:
- Link a map to a companion panel and read the brush settings back off the linker; its
selection_expris the live predicate a kernel updates as you drag:>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> linker = InteractiveMap().field(dem).cross_filter( # doctest: +SKIP ... selection_mode="intersect", unselected_alpha=0.3 ... ) >>> linker.selection_mode # doctest: +SKIP 'intersect' >>> linker.unselected_alpha # doctest: +SKIP 0.3
Source code in src/digitalearth/interactive/app/interaction.py
layer_control(*, layers=None, position='top-right', controls=None, reorder=False)
#
Build a layer manager — per-layer visibility, an opacity slider, a basemap switch (DI.13).
The three keywords are the ones the Tier-2 contract declares and the web tier answers to as well —
the layers to include, the position, the controls to expose — and the map comes back, so one call
adds a layer control on either tier (#264). The panel itself is held on the map and read back through
:attr:layer_control_panel; before, this method returned it, and so ended any chain it appeared in.
The toggle order follows draw order — the order layers is in, which is the band each layer's
kind declares and then the order they were built in within that band, so a basemap added last is
still the first toggle. reorder=True adds a ▲/▼ button per offered layer that moves it
within its band (move_layer(layer_id, index)) and re-stacks the overlay live (IN-1); it is off
by default because the buttons are furniture most maps do not need. It is still not one of the
controls: those are the vocabulary the two tiers share, and only this tier builds the reorder
buttons, so advertising it there would make the web tier refuse a name this one honours.
The control is keyed by layer id, not by the position a layer held when it was built: toggling, reordering and removing all address the layer, so the switch keeps working after the overlay is re-stacked or a layer is taken off the map.
Bokeh renders tiles in EPSG:3857 only, so the basemap switch is Web-Mercator-only — and which
way that lands depends on whether it was asked for. Left at the default controls the switch
is furniture this method offers unprompted, so a non-Mercator map drops it and logs why; named in
controls it is an explicit request, and a non-Mercator map is refused with its CRS named. That
is the one policy this module applies to an explicit basemap request — the same answer
dashboard(widgets=("basemap",)) gives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
Sequence[str] | None
|
The layers to offer, by id from
:attr: |
None
|
position
|
str
|
Which of :data: |
'top-right'
|
controls
|
Sequence[str] | None
|
Which controls to expose, from
:data: |
None
|
reorder
|
bool
|
Add a |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. The panel is :attr: |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Examples:
- One toggle per registered layer, labelled by index and element type, in draw order, carrying
each layer's id as its value — and the map comes back, so the control is part of the chain
rather than the end of it:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> fc = FeatureCollection.read_file("tests/data/points.geojson") # doctest: +SKIP >>> m = InteractiveMap().field(dem).points(fc).layer_control() # doctest: +SKIP >>> list(m.layer_control_panel[1][0].options) # doctest: +SKIP ['0: Image', '1: Points'] reorder=Trueadds the move buttons, so the overlay can be re-stacked from the control:- Unprompted, the switch is furniture: on a Web-Mercator map the controls are toggles +
opacity + basemap; on any other display CRS it is dropped (and logged) rather than
drawn misaligned:
>>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> mercator = InteractiveMap().field(dem).layer_control() # doctest: +SKIP >>> len(mercator.layer_control_panel[1]) # doctest: +SKIP 3 >>> other = InteractiveMap(crs=4326).field(dem).layer_control() # doctest: +SKIP >>> len(other.layer_control_panel[1]) # doctest: +SKIP 2 - Named outright, the same condition is refused instead, with the display CRS named:
See Also
layer_control_panel: the panel this builds, held on the map. digitalearth.base.controls.resolved_controls: the shared control vocabulary.
Source code in src/digitalearth/interactive/app/dashboard.py
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
attribute_table(features, *, linked=False, source=None)
#
Build a Tabulator attribute table of a vector FeatureCollection (DI.13 / IN-5).
With linked=False (the default) the table is a read-only view of the attributes. With
linked=True it is a two-way selection companion to the map: a Selection1D stream is
shared between the table's row selection and a map layer's element, so selecting rows highlights the
matching geometry and brushing the map selects the matching rows. Either way the cells are
disabled so the view cannot be edited into disagreeing with the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Any
|
A pyramids |
required |
linked
|
bool
|
When |
False
|
source
|
Any
|
The map layer the link listens on; defaults to the layer added last. Ignored when
|
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A |
Any
|
selectable and selection-linked to the map when |
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
Examples:
- The geometry column is dropped; what is left is the attributes, unchanged:
>>> from pyramids.feature import FeatureCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> fc = FeatureCollection.read_file("tests/data/points.geojson") # doctest: +SKIP >>> table = InteractiveMap().attribute_table(fc) # doctest: +SKIP >>> list(table.value.columns) # doctest: +SKIP ['fid'] >>> len(table.value) == len(fc) # doctest: +SKIP True linked=Truereturns a row-selectable table whose selection drives the map and back:>>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> m = InteractiveMap().points(fc) # doctest: +SKIP >>> table = m.attribute_table(fc, linked=True) # doctest: +SKIP >>> table.selection = [0, 2] # selecting rows ... # doctest: +SKIP >>> m._table_links[-1][1].index # ... drives the stream # doctest: +SKIP [0, 2]
Source code in src/digitalearth/interactive/app/dashboard.py
share(*, params=('cmap', 'extent', 'time', 'basemap'))
#
Sync the listed view parameters into the URL for a shareable, reproducible view (DI.13).
Uses panel.state.location — available only under a running panel serve. Off-server
(e.g. in a notebook or test) it returns the params it would sync rather than failing, so the
call is safe everywhere. A pyramids-backed app must be served, not exported to WASM/Pyodide
(no GDAL in the browser).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Sequence[str]
|
The view parameters to serialise into the URL query string. |
('cmap', 'extent', 'time', 'basemap')
|
Returns:
| Type | Description |
|---|---|
Any
|
The |
Source code in src/digitalearth/interactive/app/dashboard.py
dashboard(*, widgets=_DEFAULT_DASHBOARD_WIDGETS, sidebar=True, title='', template=None)
#
Wrap the map and reactive widgets into a Panel layout.
The returned object is a panel.viewable.Viewable: a sidebar (or inline row) of widgets
bound to the map's style, beside the live map. The widget set is a declared vocabulary (IN-9),
:data:_DASHBOARD_WIDGETS — "cmap" (colormap selector), "alpha" (opacity slider),
"basemap" (tile-provider selector, Web-Mercator-only) — so a name outside it is refused with a
did-you-mean rather than silently dropped, and a new widget is one entry, not another elif.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widgets
|
Sequence[str]
|
Which widgets to expose, in order. |
_DEFAULT_DASHBOARD_WIDGETS
|
sidebar
|
bool
|
Lay widgets out in a left sidebar ( |
True
|
title
|
str
|
Dashboard title (falls back to the map's |
''
|
template
|
str | None
|
A Panel template to host the app in (IN-9) — |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A |
Any
|
is given, else the row/column layout. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for an unknown widget name (with a did-you-mean), an unknown |
Examples:
- Build a dashboard with colormap + opacity controls:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> app = InteractiveMap().field(dem).dashboard(widgets=("cmap", "alpha")) # doctest: +SKIP >>> sorted({w.name for w in app.select()} & {"Colormap", "Opacity"}) # doctest: +SKIP ['Colormap', 'Opacity']
Source code in src/digitalearth/interactive/app/dashboard.py
serve(*, start=False, onload=None, periodic=None, period_ms=1000, threaded=True, num_procs=1, **kwargs)
#
Deploy the dashboard: wire its per-session state, mark it servable, optionally launch it (IN-10).
Previously this only called app.servable(). Now the deployment is modelled and its session state
is wired through pn.state: an onload hook runs per connecting session, and a periodic
callback refreshes the view on a timer — the live half of IN-10, beside :meth:export_plan's export
half. With start=True it actually launches a pn.serve server (threaded) and returns it;
otherwise it marks the app servable (for panel serve app.py) and returns the viewable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
bool
|
When |
False
|
onload
|
Callable | None
|
A no-arg callable run once per session when a viewer connects, via |
None
|
periodic
|
Callable | None
|
A no-arg callable run every |
None
|
period_ms
|
int
|
The period for |
1000
|
threaded
|
bool
|
Passed to |
True
|
num_procs
|
int
|
Passed to |
1
|
**kwargs
|
Any
|
Forwarded to :meth: |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The running |
Any
|
|
Source code in src/digitalearth/interactive/app/dashboard.py
save_app(path, *, embed=True, **kwargs)
#
Export the dashboard to a standalone HTML file (no server).
Panel's embed bakes the discrete widget states into the page, so the exported file is
interactive offline within Panel's combinatorial limits (a few discrete widgets; continuous
sliders are sampled). A live, unrestricted app must be served, not exported — and a
pyramids-backed app cannot run in WASM/Pyodide (no GDAL in the browser).
Before writing, the export is modelled with :meth:export_plan (IN-10): if embed would bake more
states than the cap, the oversize is logged with the per-widget breakdown — so a truncated file is
explained rather than discovered. :meth:export_plan lets a caller check this before calling here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Any
|
Destination |
required |
embed
|
bool
|
Bake widget states for offline interactivity ( |
True
|
**kwargs
|
Any
|
Forwarded to :meth: |
{}
|
Returns:
| Type | Description |
|---|---|
Path
|
pathlib.Path: the file written, matching the tier's |
Examples:
- Export an offline, self-contained dashboard page:
Source code in src/digitalearth/interactive/app/dashboard.py
play(*, fps=DEFAULT_FPS, loop=True, layer=None)
#
Wrap the time cube in a Panel layout with an auto-advancing Player widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fps
|
float
|
Playback frames per second (the Player interval). Defaults to
:data: |
DEFAULT_FPS
|
loop
|
bool
|
Loop at the end ( |
True
|
layer
|
str | None
|
The id of the temporal layer to animate (IN-12); |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A |
Raises:
| Type | Description |
|---|---|
ValueError
|
when no |
ImportError
|
when the |
Examples:
- Play a time cube at the shared default speed; the player steps through the cube's
own time keys, not a frame index:
>>> from pyramids.dataset.collection import DatasetCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> cube = DatasetCollection.from_files(["jan.tif", "feb.tif"]) # doctest: +SKIP >>> app = InteractiveMap().timecube(cube).play() # doctest: +SKIP >>> app[1].value == app[1].options[0] # starts on step one # doctest: +SKIP True fpsis the playback rate, translated into the Player's millisecond interval — two frames a second is a 500 ms step:- Playback needs a time cube; anything else is refused rather than played empty:
Source code in src/digitalearth/interactive/temporal/animation.py
save_animation(path, *, fps=DEFAULT_FPS, layer=None, **kwargs)
#
Export the time cube as a GIF/MP4 (matplotlib backend) or a scrubber HTML.
.gif/.mp4 materialise the DynamicMap to a finite HoloMap and render via the
matplotlib backend (.mp4 needs ffmpeg). .html writes a client-side scrubber that
plays offline with no server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Any
|
Output file ( |
required |
fps
|
float
|
Frames per second. Defaults to :data: |
DEFAULT_FPS
|
layer
|
str | None
|
The id of the temporal layer to export (IN-12); |
None
|
**kwargs
|
Any
|
Forwarded to :func: |
{}
|
Returns:
| Type | Description |
|---|---|
Path
|
pathlib.Path: the file written, matching :meth: |
Raises:
| Type | Description |
|---|---|
ValueError
|
when no |
Examples:
- Export a GIF; the returned
Pathcan be inspected or moved without re-wrapping it (#248 — this used to come back as a barestr):>>> from pyramids.dataset.collection import DatasetCollection # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> cube = DatasetCollection.from_files(["jan.tif", "feb.tif"]) # doctest: +SKIP >>> m = InteractiveMap().timecube(cube) # doctest: +SKIP >>> out = m.save_animation("rain.gif") # doctest: +SKIP >>> out.suffix, out.exists() # doctest: +SKIP ('.gif', True) - The suffix picks the writer:
.htmlis the client-side scrubber, which needs no server and no ffmpeg, andfpssets its playback rate:>>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> out = InteractiveMap().timecube(cube).save_animation( # doctest: +SKIP ... "rain.html", fps=8.0 ... ) >>> out.name # doctest: +SKIP 'rain.html' >>> "<html" in out.read_text(encoding="utf-8")[:200].lower() # doctest: +SKIP True - Exporting needs a time cube, same as :meth:
play:
Source code in src/digitalearth/interactive/temporal/animation.py
colorbar(layer_id=None, *, label=None, visible=True)
#
Show the continuous colour key of a layer (the Core name, #261, order 24).
A guide on the layer's own colour encoding rather than a show= toggle on whichever layer was
added last: it is recorded first and the HoloViews options are applied from the record, so the key
moves with its layer, goes away with it, and is carried by the figure.
Bokeh draws one colorbar per plot, whatever the opts say. Measured: two guided rasters overlaid,
each with colorbar=True and its own clabel, render a single ColorBar — the one belonging
to the layer lowest in draw order. So guiding a second layer does not stack a second bar; it decides
which layer's bar is the one drawn. That is the same one-key-per-panel limit the web tier states from
the other direction ("a second legend replaces the first"), and it is the engine's, not this tier's.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str | None
|
Which layer's key to show. |
None
|
label
|
str | None
|
What to call the key — the variable and its units, usually. It reaches the drawn bar as
HoloViews' |
None
|
visible
|
bool
|
Whether the key is drawn. |
True
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
ValueError
|
when the named layer's colour varies with nothing, or — for |
ImportError
|
when the |
Examples:
- Title the raster's colour key:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().field(dem).colorbar(label="Flow (m³/s)") # doctest: +SKIP >>> m.get_layer(m.layer_ids[0]).symbology.guide().title # doctest: +SKIP 'Flow (m³/s)' - Drop it again, by name:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().field(dem, name="flow") # doctest: +SKIP >>> m.colorbar("flow", visible=False).save("m.html").name # doctest: +SKIP 'm.html'
See Also
digitalearth.base.spec.style.Symbology.with_guide: where the guide is attached.
Source code in src/digitalearth/interactive/legends/legend.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
legend(layer_id=None, *, title=None, labels=None, visible=True)
#
Show the keyed colour list of a layer (the Core name, #261, order 24).
The same guide :meth:colorbar records, drawn as Bokeh's keyed box instead of a continuous bar. Both
methods explain one layer's color encoding and so write one guide: calling both on a layer leaves
the last title and the last visible, and draws both keys.
Bokeh builds one legend per plot, from the labelled members of the overlay, so show_legend
decides whether this layer contributes a row rather than whether it gets a box of its own —
measured: a single element with show_legend=True renders no legend at all, because there is no
overlay to build one from. A layer's row is captioned by its name=, which is what labels
renames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str | None
|
Which layer's key to show. |
None
|
title
|
str | None
|
Heading above the key. It reaches the drawn box through Bokeh's own |
None
|
labels
|
Sequence[str] | None
|
Explicit row labels, replacing the derived one. A layer contributes one row to a Bokeh legend — its own label — so this takes one entry; a count that does not match is refused rather than zipped, which would drop the difference and leave rows out of the key (the web tier's rule, for the same reason). |
None
|
visible
|
bool
|
Whether the layer contributes to the key. |
True
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain. |
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
ValueError
|
when the named layer's colour varies with nothing, or — for |
ImportError
|
when the |
Examples:
- Key a contour layer, and title the box:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().contours(dem).legend(title="Contours") # doctest: +SKIP >>> m.get_layer(m.layer_ids[0]).symbology.guide().show # doctest: +SKIP True - Or take it off again:
>>> from pyramids.dataset import Dataset # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> dem = Dataset.read_file("examples/data/acc4000.tif") # doctest: +SKIP >>> m = InteractiveMap().contours(dem).legend(visible=False) # doctest: +SKIP >>> m.save("m.html").name # doctest: +SKIP 'm.html'
See Also
digitalearth.base.spec.style.Symbology.with_guide: where the guide is attached.
Source code in src/digitalearth/interactive/legends/legend.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
get_layer(layer_id)
#
Return the description of one layer, by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str
|
The layer to look up. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Its |
LayerSpec
|
class: |
Raises:
| Type | Description |
|---|---|
KeyError
|
if no layer has that id, naming the ids that do. |
Examples:
- What a builder recorded, read back by id:
Source code in src/digitalearth/interactive/core/base.py
move_layer(layer_id, index)
#
Move a layer in draw order, by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str
|
The layer to move. |
required |
index
|
int
|
Its position afterwards, counted as a list index is — |
required |
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Raises:
| Type | Description |
|---|---|
KeyError
|
if no layer has that id. |
IndexError
|
if the position is outside the map, or outside the layer's band. |
Note
This reaches the picture: render() overlays :attr:layers bottom first, and :meth:_change
rebuilds that list in the new order.
Examples:
- Two layers, reordered by id:
Source code in src/digitalearth/interactive/core/base.py
remove_layer(layer_id)
#
Take a layer off the map, by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str
|
The layer to remove. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Raises:
| Type | Description |
|---|---|
KeyError
|
if no layer has that id, naming the ids that do — a silent no-op here would look exactly like a layer that refused to go away. |
Note
The id goes back to the pool, so a name removed and asked for again is handed back
unsuffixed: an id is reserved exactly while the layer is on the map, which is the lifetime all
four tiers share (:func:~digitalearth.base.spec.layer.free_layer_id).
The in-memory data is not forgotten. A figure_spec captured before the removal still names
it, and drawing that figure again needs it; :meth:close is where this map lets its data go.
Examples:
- A layer added and then removed leaves nothing behind:
Source code in src/digitalearth/interactive/core/base.py
replace_layer(layer)
#
Swap a layer's description for another, keeping its id and its place in draw order.
This is how a layer is restyled or re-pointed after it has been drawn: the drawer builds the element again from the new description, since a HoloViews element carries the options it was built with.
A layer of the caller's own is the exception, because there is no description to build it from. A
replacement that changes only what the figure says about such a layer — its label, its band,
whether it is drawn — is honoured, and one that changes what the element is is refused: its kind,
its source, its slice, its symbology, its filter or its group. Hand the new object to
:meth:add_layer instead (:data:~digitalearth.interactive.render.renderer.KEPT_KINDS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
LayerSpec
|
The new description. Its id names the layer it replaces. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Raises:
| Type | Description |
|---|---|
CapabilityError
|
if the replacement names a kind this tier does not draw, naming the kind and the
backend that has no drawer for it. Raised off the declaration, before a description is built
or the engine is touched. It subclasses |
KeyError
|
if no layer has that id, naming the ids that do. |
ValueError
|
if |
Examples:
- A layer re-described keeps its id and its place:
Source code in src/digitalearth/interactive/core/base.py
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 | |
set_visible(layer_id, visible=True)
#
Show or hide a layer, by id.
The layer stays on the map and in its description — which is what lets it be switched back on, and what tells a saved figure that the layer is there but not drawn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_id
|
str
|
The layer to toggle. |
required |
visible
|
bool
|
Whether it is drawn. |
True
|
Returns:
| Type | Description |
|---|---|
Self
|
This map (chainable). |
Raises:
| Type | Description |
|---|---|
KeyError
|
if no layer has that id, naming the ids that do. |
Warns:
| Type | Description |
|---|---|
UserWarning
|
when the element has no keyword to say it with — a basemap, a |
Note
Every layer is hidden on its element: Bokeh takes visible=False and draws nothing for it,
while the overlay render() composes is unchanged. That includes a layer of the caller's own.
The tier holds no description to rebuild such an element from — which is why
custom:holoviews is named in the renderer contract's UNDRAWN_KINDS — but it does hold the
object, and hiding it is the same .opts() call. It used to be described hidden and nothing
more, so a caller was told the layer was hidden while render() went on drawing it, without
even the warning above (review H8).
Examples:
- A hidden layer is still described, and comes back on:
>>> import warnings >>> from digitalearth.interactive import InteractiveMap >>> m = InteractiveMap().add_layer("mine", name="obs") >>> with warnings.catch_warnings(): # a str has no `visible` option, so this warns ... warnings.simplefilter("ignore", UserWarning) ... m.set_visible("obs", False).figure_spec.layers.is_visible("obs") False >>> with warnings.catch_warnings(): ... warnings.simplefilter("ignore", UserWarning) ... m.set_visible("obs").figure_spec.layers.is_visible("obs") True
Source code in src/digitalearth/interactive/core/base.py
add_layer(layer, *, kind=None, name=None, visible=True, band=None, source=None, symbology=None, key=None, held=None, color_field=None)
#
Register a HoloViews/GeoViews element as a map layer and return self (chainable).
The low-level entry point the capability mixins build on — every builder method ends here.
A builder of a drawn kind passes layer=None and a symbology: the layer is described first
and its drawer builds the element from that description, which is what "render from the description"
means here.
An object you build yourself is a custom layer: what a figure keeps is its description — an id, the
kind custom:holoviews, a label, a band and whether it is visible — and never the object, which has no
description to write. The object stays with the scene that was handed it, so a figure saved and loaded
again names the layer but cannot rebuild it, and another backend cannot draw it at all
(:mod:digitalearth.base.custom says which case a reader is in).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Any
|
Any HoloViews/GeoViews element (or overlay-able object), or |
required |
kind
|
str | None
|
The registered, engine-neutral kind the layer is — |
None
|
name
|
str | None
|
The caller's own name for the layer, used as its id when it is free and as its label. |
None
|
visible
|
bool
|
Whether the layer is described as visible — and, for a kind this tier draws, applied: the drawer is asked for it and the element is hidden when the tree says the layer is not drawn (its own flag, and its group's). |
True
|
band
|
str | None
|
The draw-order band, for a kind that does not imply one — what a custom layer needs, since the engine name says nothing about what it draws. |
None
|
source
|
Any
|
What the layer draws, recorded under its id; |
None
|
symbology
|
Any
|
How it looks, as values — the description its drawer reads. |
None
|
key
|
Any
|
A credential the layer's drawer needs, held on the map rather than in |
None
|
held
|
Mapping[str, Any] | None
|
The engine values this layer's drawer needs that a description cannot carry — a colormap
object, a tile provider, and the half of the caller's own keywords JSON cannot spell (the
rest is described, since M3). A value the drawer reads by name is filed by that name; the
keyword and style buckets are filed nested, under their own keys, and
:func: |
None
|
color_field
|
str | None
|
The name of the value a custom layer's colour encodes. A hand-built element
publishes no colour encoding of its own, so without this the layer has no colour key and
:meth: |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The same map instance, so builder calls chain: |
Self
|
that declined to draw the layer leaves the map as it was — the description, the registered |
Self
|
source, the held key and the id are all let go again, so nothing names a layer that was never |
Self
|
drawn. |
Raises:
| Type | Description |
|---|---|
KeyError
|
when |
Exception
|
whatever the layer's drawer raises — an
:class: |
Examples:
- Two layers of one band register in call order and return the map for chaining (any object can stand in for a HoloViews element here — the registry does not inspect it):
- A
banddecides where the element lands, not the order it was added in: a reference layer registered second is drawn beneath the data layer registered first: - With the engine installed, real elements register the same way:
Source code in src/digitalearth/interactive/core/base.py
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | |
render()
#
Compose the registered layers into one HoloViews object (overlaid with *).
Returns:
| Name | Type | Description |
|---|---|---|
Any
|
The single element when one layer is registered, an |
|
Any
|
order otherwise (an empty map renders as a blank |
|
order |
Any
|
attr: |
Any
|
put it rather than where the builder call happened to arrive. |
Raises:
| Type | Description |
|---|---|
ImportError
|
when the |
Examples:
- Two registered layers compose into an overlay in draw order (needs the engine):
>>> import holoviews as hv # doctest: +SKIP >>> from digitalearth.interactive import InteractiveMap # doctest: +SKIP >>> m = InteractiveMap() # doctest: +SKIP >>> _ = m.add_layer(hv.Points([(0, 0)])) # doctest: +SKIP >>> _ = m.add_layer(hv.Points([(1, 1)])) # doctest: +SKIP >>> overlay = m.render() # doctest: +SKIP >>> len(overlay) # doctest: +SKIP 2 - An empty map renders as a blank overlay rather than raising:
Source code in src/digitalearth/interactive/core/base.py
save(path, **kwargs)
#
Save the composed map — interactive HTML (Bokeh) or a raster via the matplotlib backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Any
|
Output file ( |
required |
**kwargs
|
Any
|
Forwarded to :func: |
{}
|
Returns:
| Type | Description |
|---|---|
Path
|
pathlib.Path: the file written — every tier's |
Path
|
result can be opened, moved or asserted on without re-wrapping it. |
Raises:
| Type | Description |
|---|---|
ImportError
|
when the |
ValueError
|
for a vector suffix ( |
Examples:
- The suffix picks the backend —
.htmlis interactive Bokeh,.pngrenders headless through matplotlib (needs the engine): - A vector file is the static tier's, and the refusal says so rather than writing one (it needs no engine: nothing is rendered for a call that cannot be honoured):
Source code in src/digitalearth/interactive/core/base.py
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 | |
show()
#
Render the map and display it inline when IPython is available.
Returns:
| Type | Description |
|---|---|
Any
|
The composed HoloViews object (which a notebook front-end renders richly). |
Raises:
| Type | Description |
|---|---|
ImportError
|
when the |
Source code in src/digitalearth/interactive/core/base.py
close()
#
Let go of the in-memory data this map registered.
The object registry is process-global and holds strong references, so a session that builds maps keeps every dataset they drew until something says otherwise. This is the caller saying so. Closing twice is harmless, and a map that registered nothing has nothing to forget.
An object: source in a figure_spec captured from this map cannot be opened afterwards — which is
what "closed" means for a figure whose data lived only in this process. Save the data and reference
it by path to keep such a figure readable.
The credentials held for keyed basemaps go too, and with them the engine values held beside each layer: they are kept off the figure so it can be written down without them, and a closed map has nothing left to draw with them.
What does not go is the figure: the layer tree, the elements already built and the pointer the
toggles follow all survive, so a closed map still renders, saves and can have its colorbar or
legend switched. Closing lets go of the data, not of the picture — a colorbar() after close()
acts on a layer that is still there, which is why the pointer is not cleared here as it is in
:meth:_forget_layer (review N8). Only a layer that was forgotten takes the pointer with it.
Examples:
- A map that drew nothing closes quietly, with no engine installed:
See Also
exit: calls this on the way out of a with block.