midlines_smooth: Uses a rolling mean to smooth midlines

View source: R/midlines_polish.R

midlines_smoothR Documentation

Uses a rolling mean to smooth midlines

Description

Uses zoo{rollapply} to smooth lines, while keeping nodes where lines meet unchanged. The dataset of ungrouped lines is returned.

Usage

midlines_smooth(x, width = 3)

Arguments

x

Feature collection of sf linestrings. The input is intended to be the output of midlines_clean

width

option passed to zoo{rollapply} "specifying the window width (in numbers of observations)" used to calculate the rolling mean

Examples

library(sf)
poly = st_buffer(st_linestring(matrix(c(0,0,10,0,10,10,0,10,0,0),ncol=2, byrow=TRUE) ),0.75)
plot(poly, col = "GRAY")

ml = midlines_clean(midlines_draw(poly, dfMaxLength = 1))
ml = ml[ml$removed_flag==0,]
plot(ml$geometry, add = TRUE)

ml_smooth = midlines_smooth(ml)
plot(poly, col = "GRAY")
plot(ml_smooth$geometry, add = TRUE)

RichardPatterson/midlines documentation built on March 25, 2024, 1:38 a.m.