destination-earth / DestinE_ESA_GFTS

Global Fish Tracking Service - DestinE DESP Use Case
https://destination-earth.github.io/DestinE_ESA_GFTS/
Apache License 2.0
10 stars 6 forks source link

Evaluate if xddgs healpix code can be ported to javascript #98

Open yellowcap opened 4 weeks ago

yellowcap commented 4 weeks ago

The xarray-xddgs library has python functions to create polygons based on heaplix cell ids.

If we can port this to javascript we could do healpix visualizations in js applications.

From a quick look, it seems like xddgs relies on heaply for the caclulations, which in turn is bundles the HEALPix C++ library. So porting to javascript might not be simple because the heavy lift of the healpix calculations happens in C at the moment.

tinaok commented 4 weeks ago

Hi @yellowcap Thats a great idia Here is the main version of xdggs https://github.com/xarray-contrib/xdggs/blob/main/xdggs/healpix.py I link to @keewis and @jmdelouis I also link to this issue https://github.com/xarray-contrib/xdggs/issues/11

yellowcap commented 2 weeks ago

Any pointers of how to go from Healpix ID to polygon would be quite helpful.

I was also wondering if there are some pre-computed layers with healpix geometries in a shapfile/geojson type format, because the grids themselves are static and could be pre-computed.

keewis commented 2 weeks ago

Any pointers of how to go from Healpix ID to polygon would be quite helpful.

xdggs provides a cell_boundaries method that returns shapely polygons (or as geoarrow, but I don't remember whether I actually exposed that switch)

I was also wondering if there are some pre-computed layers with healpix geometries in a shapfile/geojson type format

not that I'm aware of, but this should be pretty easy to create (I'd write to geoparquet, though, that's usually much faster to read than text-based formats).

yellowcap commented 2 weeks ago

Thanks @keewis great idea to just generate the necessary layers directly!

xdggs provides a cell_boundaries method that returns shapely polygons

I have seen this, but if I got it correctly, this is ultimatively being computed in C++, so to understand the actual contruction of the geometry and porting to Javascript, we will probably have to digg into the C code.

Probably its faster to pre-generate the levels that we want to use.

keewis commented 2 weeks ago

you could also use a rust library (cdshealpix?), compile that to WASM and call it from javascript?

yellowcap commented 1 week ago

Thanks @keewis good idea. @danielfdsilva something to evaluate on the Javascript side?