S2 Geography Accessors
Accessors extract information about geography vectors.
s2_is_collection(x) s2_dimension(x) s2_num_points(x) s2_is_empty(x) s2_area(x, radius = s2_earth_radius_meters()) s2_length(x, radius = s2_earth_radius_meters()) s2_perimeter(x, radius = s2_earth_radius_meters()) s2_x(x) s2_y(x) s2_distance(x, y, radius = s2_earth_radius_meters()) s2_max_distance(x, y, radius = s2_earth_radius_meters())
x, y |
geography vectors. These inputs
are passed to |
radius |
Radius of the earth. Defaults to the average radius of
the earth in meters as defined by |
BigQuery's geography function reference:
# s2_is_collection() tests for multiple geometries in one feature s2_is_collection(c("POINT (-64 45)", "MULTIPOINT ((-64 45), (8 72))")) # s2_dimension() returns 0 for point, 1 for line, 2 for polygon s2_dimension( c( "GEOMETRYCOLLECTION EMPTY", "POINT (-64 45)", "LINESTRING (-64 45, 8 72)", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "GEOMETRYCOLLECTION (POINT (-64 45), LINESTRING (-64 45, 8 72))" ) ) # s2_num_points() counts points s2_num_points(c("POINT (-64 45)", "LINESTRING (-64 45, 8 72)")) # s2_is_empty tests for emptiness s2_is_empty(c("POINT (-64 45)", "POINT EMPTY")) # calculate area, length, and perimeter s2_area("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))") s2_perimeter("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))") s2_length(s2_boundary("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")) # extract x and y coordinates from points s2_x(c("POINT (-64 45)", "POINT EMPTY")) s2_y(c("POINT (-64 45)", "POINT EMPTY")) # calculate minimum and maximum distance between two geometries s2_distance( "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "POINT (-64 45)" ) s2_max_distance( "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "POINT (-64 45)" )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.