Changes the number of shape coordinates.

coo_sample(x, n, from_col, to_col, ...)

coo_sample_prop(x, prop, from_col = coo, to_col = coo, ...)

coo_interpolate(x, n, from_col, to_col, ...)

Arguments

x

coo_single, coo_list or mom_tbl

n

integer desired number of coordinates (required)

from_col

colnames from where to get the coo_list and how to name the resulting one (only for mom_tbl method)

to_col

colnames from where to get the coo_list and how to name the resulting one (only for mom_tbl method)

...

useless here

prop

numeric desired poportion of sampled coordinates (required). Below 1 will sample, above 1 will interpolate.

Value

a coo_single, coo_list or mom_tbl

Details

coo_sample will return coordinates regularly sampled along the curvilinear abscissa. The last point will be dropped so that the distance (new last - first) roughly equals all other distances between consecutive points. This is typically useful for outlines. coo_sample_curve (todo link) will preserve the first and last points. This is typically useful for curves, hence the name. coo_interpolate will upsample the number of points. All functions have a _prop ally, where n is deduced from the proportion you want to retain.

Functions

  • coo_sample_prop: Sample a proportion of coordinates

  • coo_interpolate: Interpolates shape coordinates

See also

Examples

x <- bot %>% pick(1) %>% coo_sample(24) x %>% gg()
x %>% coo_interpolate(120) %>% gg()
bot$coo[1:2] %>% coo_sample(12) %>% purrr::map_dbl(nrow)
#> brahma caney #> 12 12
bot$coo[1:2] %>% coo_sample(12) %>% coo_interpolate(24) %>% purrr::map_dbl(nrow)
#> brahma caney #> 24 24