View source: R/set_points_sample.R
set_points_sample | R Documentation |
This function simulates the coordinates of points either regularly or
randomly distributed in two dimensions. Other point patterns
can be also chosen, see the type
argument for the sf::st_sample()
function. The points are generated within an input polygon or the
bounding box of an input raster. If no spatial object is used as input,
The size of the landscape is defined by the extent_x
and extent_y
parameters.
It assumes the landscape is square or rectangularly shaped.
set_points_sample(
n_features = 1000,
type = c("regular", "random")[1],
base_polygon = NULL,
extent_x = c(0, 1),
extent_y = extent_x
)
n_features |
|
type |
|
base_polygon |
|
extent_x , entent_y |
|
A data.frame
with the (x,y) coordinates of the simulated points.
library(sf)
pts <- set_points_sample(100)
plot(pts)
pts2 <- set_points_sample(100, type = "random")
plot(pts2)
library(raster)
x <- rast(system.file("external/test.grd", package="raster"))
pts3 <- set_points_sample(100, base_polygon = x)
plot(pts3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.