Skip to contents

Clip input raster by the expected maximum extent of computation.

Usage

clip_ras_ext(pnts = NULL, radius = NULL, ras = NULL, nqsegs = 180L)

Arguments

pnts

sf or SpatVector object

radius

numeric(1). buffer radius. This value will be automatically multiplied by 1.25

ras

SpatRaster object to be clipped

nqsegs

integer(1). the number of points per a quarter circle

Value

A clipped SpatRaster object.

Author

Insang Song

Examples

library(terra)
#> terra 1.7.78

ras_rand <- terra::rast(nrow = 20, ncol = 20)
terra::values(ras_rand) <- runif(400L)
ras_rand_p <-
  data.frame(
    x = c(3, 5, 3.2, 8),
    y = c(12, 10, 15, 12),
    z = c(0, 1, 2, 3)
  )
ras_rand_p <- terra::vect(ras_rand_p, geom = c("x", "y"))
clip_ras_ext(ras_rand_p, 1.5, ras_rand)
#> class       : SpatRaster 
#> dimensions  : 2, 1, 1  (nrow, ncol, nlyr)
#> resolution  : 18, 9  (x, y)
#> extent      : 0, 18, 0, 18  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 
#> source(s)   : memory
#> name        :     lyr.1 
#> min value   : 0.8666157 
#> max value   : 0.9528248