An open API service indexing awesome lists of open source software.

https://github.com/robinlovelace/s2sphere

Experiments with the s2 library
https://github.com/robinlovelace/s2sphere

Last synced: about 1 month ago
JSON representation

Experiments with the s2 library

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%"
)
```

# s2sphere

The goal of s2sphere is to demo geographic operations in the s2 library

## Installation

```{r, eval=FALSE}
remotes::install_github("robinlovelace/s2sphere")
```

## In python

Here's how it works in Python

```{python}
import s2sphere

r = s2sphere.RegionCoverer()
p = s2sphere.LatLng(33, -122)
p
p1 = s2sphere.LatLng.from_degrees(33, -122)
p2 = s2sphere.LatLng.from_degrees(33.1, -122.1)
cell_ids = r.get_covering(s2sphere.LatLngRect.from_point_pair(p1, p2))
print(cell_ids)
```

## In R

Proof of concept to reproduce the above code using reticulate:

```{r}
library(s2sphere)
getCellIDs(33, -122, 33.1, -122.1)
```

```{r, echo=FALSE, eval=FALSE}
library(reticulate)
s2s = import("s2sphere")
latlng = s2s$LatLng(33, -122)
s2s
class(latlng)
s2sphere::LatLng(c(3, 9))

```

```{r lib, echo=FALSE}
# ## basic example code
# p1 = s2s$convert
# os <- import("os")
```