Learn R Programming

spatialEco (version 2.0-2)

extract.vertices: Extract vertices for polygons or lines

Description

Extracts [x,y] vertices from an sf line or polygon object

Usage

extract.vertices(x, join = TRUE)

Value

An sf POINT object of extrated line or polygon vertices

Arguments

x

An sf line or polygon class object

join

(TRUE/FALSE) Joint attributes from original object

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Details

This function returns the vertices of a line or polygon object, as opposed to the polygon centroids or line start/stop coordinates

Examples

Run this code

library(sf)
nc <- sf::st_read(system.file("shape/nc.shp", package="sf"))
  nc <- suppressWarnings(sf::st_cast(nc, "POLYGON"))
    nc <- nc[c(10,50),]
  
( v <- extract.vertices(nc) )
  plot(st_geometry(nc))
    plot(st_geometry(v), pch=20, cex=2, col="red", add=TRUE)

Run the code above in your browser using DataLab