1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/s2-accessors.R
3\name{s2_is_collection}
4\alias{s2_is_collection}
5\alias{s2_is_valid}
6\alias{s2_is_valid_detail}
7\alias{s2_dimension}
8\alias{s2_num_points}
9\alias{s2_is_empty}
10\alias{s2_area}
11\alias{s2_length}
12\alias{s2_perimeter}
13\alias{s2_x}
14\alias{s2_y}
15\alias{s2_distance}
16\alias{s2_max_distance}
17\title{S2 Geography Accessors}
18\usage{
19s2_is_collection(x)
20
21s2_is_valid(x)
22
23s2_is_valid_detail(x)
24
25s2_dimension(x)
26
27s2_num_points(x)
28
29s2_is_empty(x)
30
31s2_area(x, radius = s2_earth_radius_meters())
32
33s2_length(x, radius = s2_earth_radius_meters())
34
35s2_perimeter(x, radius = s2_earth_radius_meters())
36
37s2_x(x)
38
39s2_y(x)
40
41s2_distance(x, y, radius = s2_earth_radius_meters())
42
43s2_max_distance(x, y, radius = s2_earth_radius_meters())
44}
45\arguments{
46\item{x, y}{\link[=as_s2_geography]{geography vectors}. These inputs
47are passed to \code{\link[=as_s2_geography]{as_s2_geography()}}, so you can pass other objects
48(e.g., character vectors of well-known text) directly.}
49
50\item{radius}{Radius of the earth. Defaults to the average radius of
51the earth in meters as defined by \code{\link[=s2_earth_radius_meters]{s2_earth_radius_meters()}}.}
52}
53\description{
54Accessors extract information about \link[=as_s2_geography]{geography vectors}.
55}
56\examples{
57# s2_is_collection() tests for multiple geometries in one feature
58s2_is_collection(c("POINT (-64 45)", "MULTIPOINT ((-64 45), (8 72))"))
59
60# s2_dimension() returns 0 for point, 1  for line, 2 for polygon
61s2_dimension(
62  c(
63    "GEOMETRYCOLLECTION EMPTY",
64    "POINT (-64 45)",
65    "LINESTRING (-64 45, 8 72)",
66    "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))",
67    "GEOMETRYCOLLECTION (POINT (-64 45), LINESTRING (-64 45, 8 72))"
68   )
69)
70
71# s2_num_points() counts points
72s2_num_points(c("POINT (-64 45)", "LINESTRING (-64 45, 8 72)"))
73
74# s2_is_empty tests for emptiness
75s2_is_empty(c("POINT (-64 45)", "POINT EMPTY"))
76
77# calculate area, length, and perimeter
78s2_area("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")
79s2_perimeter("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")
80s2_length(s2_boundary("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))"))
81
82# extract x and y coordinates from points
83s2_x(c("POINT (-64 45)", "POINT EMPTY"))
84s2_y(c("POINT (-64 45)", "POINT EMPTY"))
85
86# calculate minimum and maximum distance between two geometries
87s2_distance(
88  "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))",
89  "POINT (-64 45)"
90)
91s2_max_distance(
92  "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))",
93  "POINT (-64 45)"
94)
95
96}
97\seealso{
98BigQuery's geography function reference:
99\itemize{
100\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_iscollection}{ST_ISCOLLECTION}
101\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_dimension}{ST_DIMENSION}
102\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_numpoints}{ST_NUMPOINTS}
103\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_isempty}{ST_ISEMPTY}
104\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_area}{ST_AREA}
105\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_length}{ST_LENGTH}
106\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_perimeter}{ST_PERIMETER}
107\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_x}{ST_X}
108\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_y}{ST_Y}
109\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_distance}{ST_DISTANCE}
110\item \href{https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_maxdistance}{ST_MAXDISTANCE}
111}
112}
113