Learn R Programming

spatialEco (version 2.0-1)

quadrats: Quadrats

Description

Creates quadrat polygons for sampling or analysis

Usage

quadrats(x, s = 250, n = 100, r = NULL, sp = FALSE)

Value

an sf or sp polygon object with rotated polygon(s)

Arguments

x

A sp or sf polygon object defining extent

s

Radius defining single or range of sizes of quadrats

n

Number of quadrats

r

A rotation factor for random rotation, default is NULL

sp

(FALSE | TRUE) Output sp class object

Examples

Run this code
library(sf)
library(terra) 

# read meuse data and create convex hull 
 data(meuse, package = "sp")
   meuse <- st_as_sf(meuse, coords = c("x", "y"), 
                     crs = 28992, agr = "constant") 
     e <- st_convex_hull(st_union(meuse))

 # Fixed size 250 and no rotation 
 s <- quadrats(e, s = 250, n = 10)
   plot(st_geometry(s))
 
# \donttest{   
 # Variable sizes 100-300 and rotation of 0-45 degrees
 s <- quadrats(e, s = c(100,300), n = 10, r = c(0,45))
   plot(st_geometry(s))
 
 # Variable sizes 100-300 and no rotation 
 s <- quadrats(e, s = c(100,300), n = 10)
  plot(st_geometry(s))
# }   
 

Run the code above in your browser using DataLab