-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plotting using lonboard #11
Comments
I think you probably want the Either way, they're relatively layers easy to wrap, at least putting off h3 integers for later |
Yes I guess we'd have to do the same for converting s2 cell (uint64) ids to s2 tokens. |
I just tried to use The only issue I had is that I couldn't yet figure out how to zoom in on polygons in the range of 180° to 360° longitude, the map always snaps back to -180° to 0°, which does not have any data. That issue aside this has been pleasant to work with, so I wonder how much would it take to add sliders for time / depth. As far as I can tell, as long as we don't change the polygons |
Not sure I fully understand, but maybe we need to enable map-repeating? https://deck.gl/docs/whats-new#world-repeating-in-web-mercator-maps |
that could be it. Let me try to create a dummy dataset so you can see what I'm talking about. |
If you want to try reproducing, you'll need to have an environment with channels:
- conda-forge
dependencies:
- python=3.12
- jupyterlab
- geopandas
- xarray
- numpy<2.1
- lonboard
- matplotlib
- pip
- pip:
- git+https://github.com/xarray-contrib/xdggs.git and here's the code: import geopandas as gpd
import lonboard
import numpy as np
import xarray as xr
import xdggs
from lonboard.colormap import apply_continuous_cmap
from matplotlib import colormaps
from matplotlib.colors import CenteredNorm, Colormap
resolution = 5
ds = (
xr.Dataset(
coords={
"cell_ids": (
"cells",
np.arange(12 * 4**resolution),
{
"grid_name": "healpix",
"resolution": resolution,
"indexing_scheme": "nested",
},
)
}
)
.pipe(xdggs.decode)
.pipe(lambda ds: ds.merge(ds.dggs.cell_centers()))
.assign(data=lambda ds: np.sin(np.radians(ds["latitude"])))
.assign_coords(cell_boundaries=lambda ds: ds.dggs.cell_boundaries())
)
gdf = ds.to_pandas().pipe(gpd.GeoDataFrame, geometry="cell_boundaries", crs=4326)
data = gdf["data"].to_numpy()
normalizer = CenteredNorm(vcenter=0, halfrange=1)
normalized_data = normalizer(data)
cmap = colormaps["coolwarm"]
colors = apply_continuous_cmap(normalized_data, cmap)
layer = lonboard.SolidPolygonLayer.from_geopandas(
gdf, filled=True, get_fill_color=colors
)
map = lonboard.Map(layer)
map |
Are you able to post a screenshot/screencast of the issue? |
I can try to create a screencast, yes (I just need to figure out how to do that on my OS) |
I haven't seen that behavior before. Perhaps it is somehow related to deck.gl not sure which side of the earth to draw on, but that would seem weird because it's split by |
lonboard is a new tool for efficient and interactive plotting of (vector) geospatial data in Jupyter.
It would be nice to leverage it for plotting DGGS data.
Lonboard uses deck.gl in the front-end. Although this is not (yet) available in lonboard, Deck.gl has specific layers for H3 and S2 so for those two grids this could potentially be very efficient as we would only need to transfer cell ids and cell values (colors) to the front-end and let deck.gl compute and render the cells.
For the other grids, we could fallback to transfer the grid cell geometries as polygons (see #10) and use lonboard's SolidPolygonLayers.
cc @kylebarron
The text was updated successfully, but these errors were encountered: