line_on_halfplot: Extract mid‐lines from half‐plots

View source: R/utils_shapefile.R

line_on_halfplotR Documentation

Extract mid‐lines from half‐plots

Description

For each polygon in an sf object, computes the line segment joining the midpoints of the longer pair of opposite edges (the “half‐plot line”).

Usage

line_on_halfplot(shapefile)

Arguments

shapefile

An sf object of polygons. Each geometry must be closed (first and last coordinate coincide) so that st_coordinates(...) yields a repeating start point.

Value

A SpatVector (from the terra package) of line geometries representing the half‐plot midlines.

Examples


if(interactive()){
library(pliman)
shp <- shapefile_input( paste0(image_pliman(), "/soy_shape.rds"))
mosaic <- mosaic_input( paste0(image_pliman(), "/soy_dsm.tif"))
mosaic_plot(mosaic)
half <- line_on_halfplot(shp)
shapefile_plot(half, add = TRUE, col = "blue")

}

pliman documentation built on Aug. 21, 2025, 5:46 p.m.