Geography Constructors and Exporters

Convert objects to and from geography vectors

s2_lnglat() as_s2_lnglat() as.data.frame(<s2_lnglat>) as.matrix(<s2_lnglat>) as_wkb(<s2_lnglat>) as_wkt(<s2_lnglat>)

Create an S2 LngLat Vector

s2_point() as_s2_point() as.data.frame(<s2_point>) as.matrix(<s2_point>)

Create an S2 Point Vector

as_s2_geography() as_wkb(<s2_geography>) as_wkt(<s2_geography>)

Create an S2 Geography Vector

s2_geog_point() s2_make_line() s2_make_polygon() s2_geog_from_text() s2_geog_from_wkb() s2_as_text() s2_as_binary()

Create and Format Geography Vectors

Geography Transformations

Functions that operate on geography vectors and return geography vectors

s2_boundary() s2_centroid() s2_closest_point() s2_minimum_clearance_line_between() s2_difference() s2_sym_difference() s2_intersection() s2_union() s2_snap_to_grid() s2_simplify() s2_rebuild() s2_buffer_cells() s2_centroid_agg() s2_union_agg()

S2 Geography Transformations

Binary Geography Predicates

Functions that operate two geography vectors and return a logical vector

s2_contains() s2_within() s2_covered_by() s2_covers() s2_disjoint() s2_intersects() s2_equals() s2_intersects_box() s2_touches() s2_dwithin()

S2 Geography Predicates

Geography Accessors

Functions that operate one or more geography vectors and return a vector of values

s2_is_collection() s2_dimension() s2_num_points() s2_is_empty() s2_area() s2_length() s2_perimeter() s2_x() s2_y() s2_distance() s2_max_distance()

S2 Geography Accessors

s2_bounds_cap() s2_bounds_rect()

Compute feature-wise and aggregate bounds

Matrix Functions

These functions return various relationships between two geography vectors

s2_closest_feature() s2_farthest_feature() s2_distance_matrix() s2_max_distance_matrix() s2_contains_matrix() s2_within_matrix() s2_covers_matrix() s2_covered_by_matrix() s2_intersects_matrix() s2_disjoint_matrix() s2_equals_matrix() s2_touches_matrix() s2_dwithin_matrix() s2_may_intersect_matrix()

Matrix Functions

Utility Functions

s2_earth_radius_meters()

Earth Constants

s2_options() s2_snap_identity() s2_snap_level() s2_snap_precision() s2_snap_distance()

Geography Operation Options

Example Data

Useful data for testing and demonstrating s2 functions

s2_data_tbl_countries s2_data_tbl_timezones s2_data_tbl_cities s2_data_countries() s2_data_timezones() s2_data_cities()

Low-resolution world boundaries, timezones, and cities