https://github.com/jaykickliter/hextree
Trees for fast location-to-value lookup.
https://github.com/jaykickliter/hextree
geospatial gis h3
Last synced: 2 months ago
JSON representation
Trees for fast location-to-value lookup.
- Host: GitHub
- URL: https://github.com/jaykickliter/hextree
- Owner: JayKickliter
- License: apache-2.0
- Created: 2022-08-17T22:18:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-02T21:38:00.000Z (5 months ago)
- Last Synced: 2025-03-29T11:07:09.284Z (3 months ago)
- Topics: geospatial, gis, h3
- Language: Rust
- Homepage:
- Size: 7.98 MB
- Stars: 57
- Watchers: 6
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
[](https://github.com/JayKickliter/HexTree/actions/workflows/rust.yml) [](https://docs.rs/hextree)
# HexTree
hextree provides tree structures that represent geographic regions
with [H3 cell]s.The primary structures are:
- [**HexTreeMap**]: an H3 cell-to-value map.
- [**HexTreeSet**]: an H3 cell set for hit-testing.You can think of `HexTreeMap` vs. `HexTreeSet` as [`HashMap`] vs. [`HashSet`].
## How is this different from `HashMap`?
The key feature of a hextree is that its keys (H3 cells) are
hierarchical. For instance, if you previously inserted an entry for a
low-res cell, but later query for a higher-res child cell, the tree
returns the value for the lower res cell. Additionally, with
[compaction], trees can automatically coalesce adjacent high-res cells
into their parent cell. For very large regions, the compaction process
_can_ continue to lowest resolution cells (res-0), possibly removing
millions of redundant cells from the tree. For example, a set of
4,795,661 res-7 cells representing North America coalesces [into a
42,383 element `HexTreeSet`][us915].A hextree's internal structure exactly matches the semantics of an [H3
cell]. The root of the tree has 122 resolution-0 nodes, followed by 15
levels of 7-ary nodes. The level of an occupied node, or leaf node, is
the same as its corresponding H3 cell resolution.## Features
* **`serde`**: support for serialization via [serde].
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE] or )
* MIT license ([LICENSE-MIT] or )at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the
Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.[`HashMap`]: https://doc.rust-lang.org/std/collections/struct.HashMap.html
[`HashSet`]: https://doc.rust-lang.org/std/collections/struct.HashSet.html
[H3 cell]: https://h3geo.org/docs/core-library/h3Indexing
[serde]: https://docs.rs/serde/latest/serde
[compaction]: crate::compaction
[us915]: https://kepler.gl/demo?mapUrl=https://gist.githubusercontent.com/JayKickliter/8f91a8437b7dd89321b22cde50e71c3a/raw/4aafc62303d913edf58ac1bb7b3b656c8df188a1/us915.kepler.json
[**HexTreeMap**]: crate::HexTreeMap
[**HexTreeSet**]: crate::HexTreeSet
[LICENSE-APACHE]: https://github.com/JayKickliter/HexTree/blob/main/LICENSE-APACHE
[LICENSE-MIT]: https://github.com/JayKickliter/HexTree/blob/main/LICENSE-MIT