Skip to content
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

Use 1D Hilbert curves instead of 3D Q2DI? #118

Open
danlooo opened this issue Oct 10, 2024 · 0 comments
Open

Use 1D Hilbert curves instead of 3D Q2DI? #118

danlooo opened this issue Oct 10, 2024 · 0 comments

Comments

@danlooo
Copy link
Owner

danlooo commented Oct 10, 2024

Currently, DGGS native data cubes are stored in a 3D index i.e. Q2DI. However, address space in RAM and disk is 1D. Space filling curves, e.g. the Hilbert, transform a multi dimensional index into 1D while preserving spatial locality.

Tiling and 3D index

  • Trivial neighbour retrieval (x -> x + 1)
  • used by raster data (GeoTIF, Map tiles, Zarr chunking, JPEG blocks)
  • More memory access (if tile size >> kernel size)
  • Faster neighborhood calculation

Hilbert curves and 1D index

  • Less memory access
  • Used by vector data (PostGIS, FlatGeobuff)
  • need to convert between 1D Hilbert and 2D coordinates every time to get neighbors (complex algo, can be cached in self similar curve)
  • a bounding box can have many Hilbert intervals (No bbox to hilbert encoding found in Julia. Only pixel by pixel)
  • used to assign data chunks to nodes in cluster computing (but not at lower level e.g. assign pixels)
  • not implemented, e.g. no xarray extension

Conclusion

DGGS native data cubes are raster data. Just tiling should be faster than using the additional Hilbert index for reasonable tile sizes i.e. similar to window and kernel size (Google map tiles are 256*256px, S3 chunks should be ~10MB i.e. 1024px * 1024px double is 8.3MB). Trade off using Hilbert curves: caching size vs reduced number of RAM lookups.

@danlooo danlooo changed the title Use 1D Hilbert curves instead of 3D Q2DI Use 1D Hilbert curves instead of 3D Q2DI? Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant