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
- Host: GitHub
- URL: https://github.com/robinlovelace/s2sphere
- Owner: Robinlovelace
- Created: 2019-09-05T09:47:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-05T13:43:03.000Z (over 5 years ago)
- Last Synced: 2025-04-03T16:12:21.924Z (about 2 months ago)
- Language: R
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
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 s2spherer = 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")
```