A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://r-spatial.github.io/s2/reference/s2_boundary.html below:

S2 Geography Transformations — s2_boundary • s2

# returns the boundary:
# empty for point, endpoints of a linestring,
# perimeter of a polygon
s2_boundary("POINT (-64 45)")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] GEOMETRYCOLLECTION EMPTY
s2_boundary("LINESTRING (0 0, 10 0)")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] MULTIPOINT ((0 0), (10 0))
s2_boundary("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] LINESTRING (0 0, 10 0, 10 10, 0 10, 0 0...

# returns the area-weighted centroid, element-wise
s2_centroid("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (5 5.00595863)
s2_centroid("LINESTRING (0 0, 10 0)")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (5 0)

# s2_point_on_surface guarantees a point on surface
# Note: this is not the same as st_point_on_surface
s2_centroid("POLYGON ((0 0, 10 0, 1 1, 0 10, 0 0))")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (2.00377112 2.00234355)
s2_point_on_surface("POLYGON ((0 0, 10 0, 1 1, 0 10, 0 0))")
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (0.450236802 0.450222902)

# returns the unweighted centroid of the entire input
s2_centroid_agg(c("POINT (0 0)", "POINT (10 0)"))
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (5 0)

# returns the closest point on x to y
s2_closest_point(
  "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
  "POINT (0 90)" # north pole!
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (5 10.037423)

# returns the shortest possible line between x and y
s2_minimum_clearance_line_between(
  "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
  "POINT (0 90)" # north pole!
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] LINESTRING (5 10.037423, 0 90)

# binary operations: difference, symmetric difference, intersection and union
s2_difference(
  "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
  "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))",
  # 32 bit platforms may need to set snap rounding
  s2_options(snap = s2_snap_level(30))
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POLYGON ((5.00000004 10.0374231, 3.55739019e-08 10, 3.55739019e-08 3.55739019e-08, 10 3.50334544e-08, 10 5.01900178...

s2_sym_difference(
  "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
  "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))",
  # 32 bit platforms may need to set snap rounding
  s2_options(snap = s2_snap_level(30))
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] MULTIPOLYGON (((5.00000004 10.0374231, 3.55739019e-08 10, 3.55739019e-08 3.55739019e-08, 10 3.50334544e-08, 10 5.01900178...

s2_intersection(
  "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
  "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))",
  # 32 bit platforms may need to set snap rounding
  s2_options(snap = s2_snap_level(30))
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POLYGON ((5.00000004 4.99999997, 10 5.01900178, 10 9.99999999, 5.00000004 10.0374231, 5.00000004 4.99999997...

s2_union(
  "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
  "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))",
  # 32 bit platforms may need to set snap rounding
  s2_options(snap = s2_snap_level(30))
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POLYGON ((5.00000004 10.0374231, 3.55739019e-08 10, 3.55739019e-08 3.55739019e-08, 10 3.50334544e-08, 10 5.01900178...

# s2_convex_hull_agg builds the convex hull of a list of geometries
s2_convex_hull_agg(
  c(
    "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
    "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))"
  )
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POLYGON ((0 0, 10 0, 15 5, 15 15, 5 15...

# use s2_union_agg() to aggregate geographies in a vector
s2_coverage_union_agg(
  c(
    "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
    "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))"
  ),
  # 32 bit platforms may need to set snap rounding
  s2_options(snap = s2_snap_level(30))
)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] MULTIPOLYGON (((3.55739019e-08 3.55739019e-08, 10 3.50334544e-08, 10 9.99999999, 3.55739019e-08 10, 3.55739019e-08 3.55739019e-08...

# snap to grid rounds coordinates to a specified grid size
s2_snap_to_grid("POINT (0.333333333333 0.666666666666)", 1e-2)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (0.33 0.67)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4