Low-level wk filters and handlers

s2_unprojection_filter(
  handler,
  projection = s2_projection_plate_carree(),
  tessellate_tol = Inf
)

s2_projection_filter(
  handler,
  projection = s2_projection_plate_carree(),
  tessellate_tol = Inf
)

s2_projection_plate_carree()

s2_projection_mercator()

Arguments

handler

A wk_handler object.

projection

One of s2_projection_plate_carree() or s2_projection_mercator()

tessellate_tol

An angle in radians. Points will not be added if a line segment is within this distance of a point.

Value

  • s2_unprojection_filter(), s2_projection_filter(): A new_wk_handler()

  • s2_projection_plate_carree(), s2_projection_mercator(): An external pointer to an S2 projection.

Examples

library(wk) # simple conversion of individual coordinates *to* unit sphere # space wk_handle( wkt("LINESTRING (0 0, 0 45, -60 45)"), s2_unprojection_filter(wkt_format_handler(5)) )
#> [1] "LINESTRING Z (1 0 0, 0.70711 0 0.70711, 0.35355 -0.61237 0.70711)"
# simple conversion of individual coordinates *from* unit sphere # space wk_handle( wkt("LINESTRING Z (1 0 0, 0.7071 0 0.7071, 0.3536 -0.6124 0.7071)"), s2_projection_filter(wkt_format_handler(5)) )
#> [1] "LINESTRING (0 0, 0 45, -59.998 44.998)"
# use tessellate_tol to force points to be added to an edge # unprojection will ensure an edge maintains its cartesian # assumption when transformed to the unit sphere # (i.e., what you probably want when importing a geography) wk_handle( wkt("LINESTRING (0 0, 0 45, -60 45)"), s2_unprojection_filter(wkt_format_handler(5), tessellate_tol = 0.001) )
#> [1] "LINESTRING Z (1 0 0, 0.70711 0 0.70711, 0.70559 -0.046247 0.70711, 0.70106 -0.092296 0.70711, 0.69352 -0.13795 0.70711, 0.68301 -0.18301 0.70711..."
# projection will ensure an edge maintains its geodesic # assumption when transformed to projected space # (i.e., what you probably want when exporting a geography) wk_handle( wkt("LINESTRING Z (1 0 0, 0.7071 0 0.7071, 0.3536 -0.6124 0.7071)"), s2_projection_filter(wkt_format_handler(5), tessellate_tol = 0.001) )
#> [1] "LINESTRING (0 0, 0 45, -3.4459 45.927, -7.0019 46.747, -10.66 47.453, -14.409 48.04..."