Hi,
I tried to use line_segment just now by segment length and got an error Error in Ops.units(n_segments, 1) : both operands of the expression should be "units" objects. It worked as expected if I run the same code but passing the function n_segments.
sf %>%
line_segment(segment_length = set_units(20, 'm'))
I think the problem is that from_to_sequence = seq(from = 0, to = 1, length.out = n_segments + 1) doesn't work if the n_segments argument has a unit (even if the unit is [1] as in this case).
I made a local copy of the function and could make it work by making the following change:
old: n_segments <- round(l_length/segment_length)
new: n_segments <- as.numeric(round(l_length/segment_length))
Hi, I tried to use
line_segment
just now by segment length and got an errorError in Ops.units(n_segments, 1) : both operands of the expression should be "units" objects
. It worked as expected if I run the same code but passing the function n_segments.sf %>% line_segment(segment_length = set_units(20, 'm'))
I think the problem is that
from_to_sequence = seq(from = 0, to = 1, length.out = n_segments + 1)
doesn't work if the n_segments argument has a unit (even if the unit is [1] as in this case).I made a local copy of the function and could make it work by making the following change: old: n_segments <- round(l_length/segment_length) new: n_segments <- as.numeric(round(l_length/segment_length))
Happy to provide more code or a regex if needed.