Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/program--/hilbert
R :package: for Hilbert Curve indexing of coordinates
https://github.com/program--/hilbert
hilbert-curve r spatial
Last synced: 24 days ago
JSON representation
R :package: for Hilbert Curve indexing of coordinates
- Host: GitHub
- URL: https://github.com/program--/hilbert
- Owner: program--
- License: other
- Created: 2022-03-09T17:43:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-08T15:31:34.000Z (over 2 years ago)
- Last Synced: 2024-06-11T17:04:39.952Z (7 months ago)
- Topics: hilbert-curve, r, spatial
- Language: R
- Homepage: https://hilbert.justinsingh.me
- Size: 1.55 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# hilbert
[![CRAN status](https://www.r-pkg.org/badges/version/hilbert)](https://CRAN.R-project.org/package=hilbert)
[![Codecov test coverage](https://codecov.io/gh/program--/hilbert/branch/main/graph/badge.svg)](https://app.codecov.io/gh/program--/hilbert?branch=main)
[![R-CMD-check](https://github.com/program--/hilbert/workflows/R-CMD-check/badge.svg)](https://github.com/program--/hilbert/actions)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)**hilbert** provides utilities for quick indexing/encoding of coordinates to a Hilbert Curve.
## Installation
You can install **hilbert** via either `remotes` or `pak`:
``` r
# pak
pak::pkg_install("program--/hilbert")# remotes
remotes::install_github("program--/hilbert")
```## Example
### Setting Up
```{r setup}
x <- -77.85641
y <- 34.35935
n <- 24 # n > 15 requires `bit64`
e <- c(xmax = 180, xmin = -180, ymax = 90, ymin = -90)
```### Coordinates to Position
```{r coords2pos}
pos <- hilbert::coords_to_position(x, y, n = n, extent = e)
pos
```### Position to Index
```{r pos2index}
index <- hilbert::index(pos, coords = c("x", "y"), n = n, attach = TRUE)
index
```### Index to Position
```{r index2pos}
new_pos <- hilbert::position(index, idx = "h", n = n, attach = FALSE)
new_pos
```### Position to Coordinates
```{r pos2coords}
new_xy <- hilbert::position_to_coords(new_pos, coords = c("x", "y"), extent = e, n = n, attach = TRUE)
new_xy
```