UXARRAY / uxarray

Xarray-styled package for reading and directly operating on unstructured grid datasets following UGRID conventions
https://uxarray.readthedocs.io/
Apache License 2.0
142 stars 31 forks source link

Better integration with Lonboard for interactive vector data viz? #765

Open kafitzgerald opened 3 months ago

kafitzgerald commented 3 months ago

Proposed new feature or change:

I was messing around with lonboard today and it seems like it provides a fairly easy way to do some more performant interactive vector data viz.

I imagine there are ways to speed this up further if we could avoid some of the conversions. I don't know enough about Uxarray or GeoParquet / GeoArrow to know how much of a lift it would be to anything here though.

This is a quick example to visualize an unstructured grid:

from lonboard import viz
import uxarray as ux

grid = ux.open_grid("~/Downloads/grid.nc")
gdf = grid.to_geodataframe().to_geopandas() # needs a geopandas.GeoDataFrame rather than a spatialpandas object
viz(gdf)

I couldn't get the conversion to a geopandas.GeoDataFrame to finish on my laptop for the 3.75km MPAS grid, but the 30km one completed and the visualization performance was great.

philipc2 commented 3 months ago

Hi @kafitzgerald

This tool looks really promising! The long execution time for going from spatialpandas to geopandas can probably be avoided if we add support for directly converting a UxDataArray to a geopandas.GeoDataFrame.

Do you have a screenshot of the resulting plot? I'll be giving this a look through soon.

kafitzgerald commented 3 months ago

I think it might just be the conversion to the Spatialpandas GeoDataFrame that's taking the bulk of the time (I see a warning about this from UxArray in both the case where I plot with Bokeh and with Lonboard). And timing for converting from a UxDataArray to Spatialpandas object was similar to UxDataArray to Spatialpandas to GeoPandas. I can grab those if that's helpful.

And here's a quick screenshot after zooming in just a bit so we can see the 30km grid (w/ all default options):

Screen Shot 2024-04-17 at 10 52 42 AM

No rush to look into this or do anything on my end. I mostly just wanted to share in case it was of interest.