Description Usage Arguments Details Value Examples

The S2 cell indexing system forms the basis for spatial indexing in the S2 library. On their own, S2 cells can represent points or areas. As a union, a vector of S2 cells can approximate a line or polygon. These functions allow direct access to the S2 cell indexing system and are designed to have minimal overhead such that looping and recursion have acceptable performance when used within R code.

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 | ```
s2_cell(x = character())
s2_cell_sentinel()
s2_cell_invalid()
s2_cell_sentinel()
as_s2_cell(x, ...)
## S3 method for class 's2_cell'
as_s2_cell(x, ...)
## S3 method for class 'character'
as_s2_cell(x, ...)
## S3 method for class 's2_geography'
as_s2_cell(x, ...)
## S3 method for class 's2_lnglat'
as_s2_cell(x, ...)
## S3 method for class 's2_point'
as_s2_cell(x, ...)
new_s2_cell(x)
``` |

`x` |
The canonical S2 cell identifier as a character vector. |

`...` |
Passed to methods |

Under the hood, S2 cell vectors are represented in R as vectors
of type `double()`

. This works because S2 cell identifiers are
64 bits wide, as are `double`

s on all systems where R runs (The
same trick is used by the bit64 package to represent signed
64-bit integers). As a happy accident, `NA_real_`

is not a valid
or meaningful cell identifier, so missing value support in the
way R users might expect is preserved. It is worth noting that
the underlying value of `s2_cell_sentinel()`

would normally be
considered `NA`

; however, as it is meaningful and useful when
programming with S2 cells, custom `is.na()`

and comparison methods
are implemented such that `s2_cell_sentinel()`

is greater than
all valid S2 cells and not considered missing. Users can and should
implement compiled code that uses the underlying bytes of the
vector, ensuring that the class of any returned object that should
be interpreted in this way is constructed with `new_s2_cell()`

.

An object of class s2_cell

1 2 3 | ```
s2_cell("4b59a0cd83b5de49")
as_s2_cell(s2_lnglat(-64, 45))
as_s2_cell(s2_data_cities("Ottawa"))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.