| a5_line_string_to_cells | R Documentation |
Returns, for each linestring feature, the A5 cells at resolution whose
pentagons the great-circle path through its waypoints crosses. Each
path's cells are uncompacted and in order along it, with duplicates
removed first-seen; a MULTILINESTRING feature's parts are traced in
order into one path.
a5_line_string_to_cells(x, resolution, simplify = TRUE)
x |
A linestring-like geometry. One of:
|
resolution |
Integer scalar target resolution (0–30). |
simplify |
Logical scalar. If |
Consecutive waypoints are connected by great-circle arcs (not rhumb lines or planar segments), so antimeridian-crossing paths work transparently when written in unwrapped lon/lat. A line string with a single waypoint gives the cell containing it.
A path is an ordered sequence, so the result is a vector of cells rather
than an a5_covering; use as_a5_covering() to treat the cells a path
crosses as a set.
Matrix and data.frame inputs are treated as a single linestring;
for multi-feature data, pass an sf, sfc, wk, or SpatVector
geometry instead.
An a5_cell vector at resolution, or an a5_cell_list when
simplify = FALSE. A missing or empty geometry contributes no cells (an
empty element in the list form).
a5_polygon_to_cells(), a5_grid_disk().
line <- wk::wkt("LINESTRING (2.35 48.86, -0.13 51.51)")
cells <- a5_line_string_to_cells(line, resolution = 6)
cells
# One path per feature
lines <- wk::wkt(c(
"LINESTRING (2.35 48.86, -0.13 51.51)",
"LINESTRING (2.35 48.86, 4.83 45.76)"
))
paths <- a5_line_string_to_cells(lines, resolution = 6, simplify = FALSE)
lengths(paths)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.