Learn R Programming

spatialEco (version 2.0-1)

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

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>

Examples

Run this code

if(require(sf, quietly = TRUE)) {
  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