-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
50 lines (36 loc) · 1.53 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Get Census Tract ID for Exact Locations
<!-- badges: start -->
[](https://github.com/geomarker-io/tract/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=tract)
<!-- badges: end -->
## Installation
You can install the development version of tract from GitHub with:
``` r
# install.packages("devtools")
devtools::install_github("geomarker-io/tract")
```
## Example
In R, get census tract identifiers for exact locations and years using the `get_census_tract_id()` function:
```{r example}
library(tract)
get_census_tract_id(
s2::as_s2_cell(c("8841b399ced97c47", "8841b38578834123")),
year = "2020")
```
## S2 geohash
The [s2 geohash](https://s2geometry.io/) is a [hierarchical](https://s2geometry.io/devguide/s2cell_hierarchy.html) geospatial index that uses [spherical geometry](https://s2geometry.io/about/overview). In R, s2 cells can be [created](https://r-spatial.github.io/s2/reference/s2_cell.html#ref-examples) using their character string representation, or by specifying latitude and longitude coordinates; e.g.:
```{r}
s2::s2_lnglat(c(-84.4126, -84.5036), c(39.1582, 39.2875)) |> s2::as_s2_cell()
```