Skip to content

Commit 56928c4

Browse files
authored
allow specifying additional coords to include in the pixel inspection table (#123)
* support passing additional coords to the plot table * expose the additional coords in the accessor * changelog
1 parent 79454cd commit 56928c4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## New features
66

7+
- allow adding additional coords to the cell inspection table in the map ({pull}`122`)
8+
79
## Bug fixes
810

911
- use explicit `arrow` API to extract cell coordinates ({issue}`113`, {pull}`114`)

xdggs/accessor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def cell_boundaries(self):
174174
boundaries, coords={self._name: self.cell_ids}, dims=self.cell_ids.dims
175175
)
176176

177-
def explore(self, *, cmap="viridis", center=None, alpha=None):
177+
def explore(self, *, cmap="viridis", center=None, alpha=None, coords=None):
178178
"""interactively explore the data using `lonboard`
179179
180180
Requires `lonboard`, `matplotlib`, and `arro3.core` to be installed.
@@ -187,6 +187,8 @@ def explore(self, *, cmap="viridis", center=None, alpha=None):
187187
If set, will use this as the center value of a diverging color map.
188188
alpha : float, optional
189189
If set, controls the transparency of the polygons.
190+
coords : list of str, default: ["latitude", "longitude"]
191+
Additional coordinates to contain in the table of contents.
190192
191193
Returns
192194
-------
@@ -207,4 +209,5 @@ def explore(self, *, cmap="viridis", center=None, alpha=None):
207209
cmap=cmap,
208210
center=center,
209211
alpha=alpha,
212+
coords=coords,
210213
)

xdggs/plotting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def explore(
4545
cmap="viridis",
4646
center=None,
4747
alpha=None,
48+
coords=None,
4849
):
4950
import lonboard
5051
from lonboard import SolidPolygonLayer
@@ -66,7 +67,7 @@ def explore(
6667
colormap = colormaps[cmap] if isinstance(cmap, str) else cmap
6768
colors = apply_continuous_cmap(normalized_data, colormap, alpha=alpha)
6869

69-
table = create_arrow_table(polygons, arr)
70+
table = create_arrow_table(polygons, arr, coords=coords)
7071
layer = SolidPolygonLayer(table=table, filled=True, get_fill_color=colors)
7172

7273
return lonboard.Map(layer)

0 commit comments

Comments
 (0)